Upgrading App from .NET 3.5 to 4.0, COM fails now - com

I have an application that I am upgrading from the .NET 3.5 to the .NET 4.0 framework. It uses a COM library which is referenced. It works no problem in 3.5 but after converting to 4.0 I have issues getting the COM to work. The COM is from a 3rd party so we didn't develop it ourselves.
I get the following COM error (generic COM error, not specific to the COM object itself): hr = 0x8007000b
CLR gives me: 'The invocation of the constructor on type 'Skype_Business_Launcher.Main' that matches the specified binding constraints threw an exception.' Line number '3' and line position '5'.
And the C# logs:
=== Pre-bind state information ===
LOG: User = \phillip
LOG: DisplayName = Interop.SKYPE4COMLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Skype Business Launcher, Version=1.0.5.0, Culture=neutral, PublicKeyToken=null.
LOG: This bind starts in default load context.
LOG: Using application configuration file:
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///bin/Debug/Interop.SKYPE4COMLib.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
I removed the pathname for security reasons but I have checked all the path information and it's all correct. Also the COM library file exists where it's pointing to. It's also copied to the OBJ folder within the project as well.
Originally I was getting an error about the COM library not supporting embedded types so I made "Embed Interop Types" false (it was true below) and the error went away but I'm not sure if thats connected to this error or not so I thought I'd mention it just in case.
Again, it works just fine with 3.5.
Thanks,

A shot in the dark: it looks like you are using the x64 version of the framework. Was that already the case with 3.5 ? And is the COM server a DLL or an EXE ?
If the COM server is a DLL, there needs to be a "bitness" match between the DLL and your program.

when you convert your project to 4.0 the IDE can perform a issue to convert COM library into 4.0.
when you convert your project to 4.0 remove com library then Re include it in your project then i thing it should be works.

Related

Load Standard library in .net core application

i have created one library using .net standard , am trying to use that in .net core api ,
but am getting error -
Error constructing handler for request of type MediatR.IRequestHandler`2[]. Register your handlers with the container. See the samples in GitHub for examples.
inner exception -
Could not load file or assembly 'RedisHelper.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
my mediatr injection as follow -
services.AddMediatR(Assembly.GetExecutingAssembly());
my class DI -
services.AddTransient<IRedisClient, RedisClient>();
can any one suggest me what i am missing here .
Thanks
Error constructing handler for request of type
MediatR.IRequestHandler`2[]. Register your handlers with the
container. See the samples in GitHub for examples.
inner exception - Could not load file or assembly 'RedisHelper.Client,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system
cannot find the file specified.
As the exception message said, could not load the RedisHelper.Client assembly. Please check your .net core application and the .net standard library, where you add this assembly? Please ensure it adds success, you could also try to re-install it.
Besides, if you add the RedisHelper.Client assembly in the library, you should also add it in the .net core application.

Unit tests pass with "dotnet test" but fail when run from Visual Studio 2017 Test Explorer

My XUnit 2.2 tests all pass when run from the command line with dotnet test. When running them from Visual Studio 2017's Test Explorer some of the tests fail with Assembly Binding errors.
My test project targets .Net 4.6.2 and references an ASP.Net Core 1.1 application also targeting .Net 4.6.2. The unit tests were working fine in VS 2015 prior to upgrading to the .NET Core 1.1 release tooling and Visual Studio 2017.
The workaround was to create an app.config file for the test project and add all of the needed binding redirects to it via trial and error. I'm not sure why I have to do this, though.
It appears that when using dotnet test the runtime uses the newer assembly versions without complaint. When running from Visual Studio, the redirects are necessary.
Why is there a difference in the assembly binding behavior between these two methods of running the tests?
Sample assembly binding error:
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.x86.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Extensions.Configuration.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
(Fully-specified)
LOG: Appbase = file:///C:/xx/xx/xx.Tests/bin/Debug/net462
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = C:\Users\xxxxx\AppData\Local\Temp\a1ec4d3c-04ff-4fa0-9e56-129e799dd870
LOG: AppName = a1ec4d3c-04ff-4fa0-9e56-129e799dd870
Calling assembly : Serilog.Settings.Configuration, Version=2.2.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.x86.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Extensions.Configuration.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/xx/xx/xx.Tests/bin/Debug/net462/Microsoft.Extensions.Configuration.Abstractions.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\xx\xx\xx.Tests\bin\Debug\net462\Microsoft.Extensions.Configuration.Abstractions.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: Microsoft.Extensions.Configuration.Abstractions, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Setup failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
And the redirect needed to solve it:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" culture="neutral" publicKeyToken="adb9793829ddae60" />
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.1.1.0" />"
</dependentAssembly>
It turns out this issue is being tracked at https://github.com/Microsoft/vstest/issues/428
The workaround is to add the following two items to the test project's csproj file:
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
This eliminates the need for manually adding binding redirects.

VB.NET desktop application error : Could not load file or assembly 'log4net, Version = 1.2.10.0 Culture = neutral, PublicKeyToken = 692fbea5521e1304'

I've setup a VB.NET desktop application in a Windows 8.1 pro 64-bit PC. After doing server configurations I'm trying to login to the application. It's when I'm getting the following error message:
Could not load file or assembly 'log4net, Version = 1.2.10.0 Culture = neutral, PublicKeyToken = 692fbea5521e1304'or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I've installed SAP Crystal Reports 13.0.3 64-bit yet it's still not working.
What is the reason behind this problem?
Check you Application files in Project Settings,find status of log4net dll whether included or not .Make it included in your project as below :
Problem solved.
The problem raised due to the mismatch in version of the log4net.dll file. My solution had log4net version = 1.2.9.0, while it needed the version = 1.2.10.0, hence the exception occured. I replaced the existing log4net.dll file with the one which has appropriate version and the problem was solved.

ASP.NET Register Assembly error

I am WAY out of my league here, so I apologize if I'm asking a duplicate question, but I don't know where to start on this one.
I recently migrated an SQL database from SERVER1, where it was collocated with IIS hosting the web interface to access the database, to SERVER2. The web interface is now accessing the database properly, and through some application features I can access the data properly, with no error. However, when I try to run a report, I get this error:
How do I fix this?
Server Error in '/' Application.
--------------------------------------------------------------------------------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 5: Namespace="AjaxControlToolkit"
Line 6: TagPrefix="ajaxToolkit" %>
Line 7: <%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Line 8: Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
Line 9:
Source File: /source/Report5.aspx Line: 7
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.4028
UPDATE
I turned on logging and got this more detailed error:
=== Pre-bind state information ===
LOG: User = AURORAFCS\raj
LOG: DisplayName = Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Family/
LOG: Initial PrivatePath = C:\Family\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Family\web.config
LOG: Using host configuration file: \\?\c:\windows\microsoft.net\framework\v2.0.50727\aspnet.config
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/dc46260e/807e5b0d/Microsoft.ReportViewer.WebForms.DLL.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/dc46260e/807e5b0d/Microsoft.ReportViewer.WebForms/Microsoft.ReportViewer.WebForms.DLL.
LOG: Attempting download of new URL file:///C:/Family/bin/Microsoft.ReportViewer.WebForms.DLL.
LOG: Attempting download of new URL file:///C:/Family/bin/Microsoft.ReportViewer.WebForms/Microsoft.ReportViewer.WebForms.DLL.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/dc46260e/807e5b0d/Microsoft.ReportViewer.WebForms.EXE.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/dc46260e/807e5b0d/Microsoft.ReportViewer.WebForms/Microsoft.ReportViewer.WebForms.EXE.
LOG: Attempting download of new URL file:///C:/Family/bin/Microsoft.ReportViewer.WebForms.EXE.
LOG: Attempting download of new URL file:///C:/Family/bin/Microsoft.ReportViewer.WebForms/Microsoft.ReportViewer.WebForms.EXE.
UPDATE2
Using fusion logger, I have this more detailed message, which shoes it a is a "File Cannot Be Found" error. However, I have installed the redistributables, so why can it not find the DLL?
*** Assembly Binder Log Entry (11/21/2014 # 4:00:35 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = AURORAFCS\raj
LOG: DisplayName = Microsoft.ReportViewer.WebForms, Version=8.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Partial)
LOG: Appbase = file:///C:/Family/
LOG: Initial PrivatePath = C:\Family\bin
LOG: Dynamic Base = c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\dc46260e
LOG: Cache Base = c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\dc46260e
LOG: AppName = 807e5b0d
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Family\web.config
LOG: Using host configuration file: \\?\c:\windows\microsoft.net\framework\v2.0.50727\aspnet.config
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/dc46260e/807e5b0d/Microsoft.ReportViewer.WebForms.DLL.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/dc46260e/807e5b0d/Microsoft.ReportViewer.WebForms/Microsoft.ReportViewer.WebForms.DLL.
LOG: Attempting download of new URL file:///C:/Family/bin/Microsoft.ReportViewer.WebForms.DLL.
LOG: Attempting download of new URL file:///C:/Family/bin/Microsoft.ReportViewer.WebForms/Microsoft.ReportViewer.WebForms.DLL.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/dc46260e/807e5b0d/Microsoft.ReportViewer.WebForms.EXE.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/dc46260e/807e5b0d/Microsoft.ReportViewer.WebForms/Microsoft.ReportViewer.WebForms.EXE.
LOG: Attempting download of new URL file:///C:/Family/bin/Microsoft.ReportViewer.WebForms.EXE.
LOG: Attempting download of new URL file:///C:/Family/bin/Microsoft.ReportViewer.WebForms/Microsoft.ReportViewer.WebForms.EXE.
LOG: All probing URLs attempted and failed.
You need to determine what version of the ReportViewer Control you are targeting and install the proper package on the same server that your web app is deployed.
Microsoft Report Viewer 2010 Redistributable Package
Microsoft Report Viewer 2008 SP1 Redistributable
Microsoft Report Viewer Redistributable 2008
Microsoft Report Viewer Redistributable 2005
I am sure the logic is as follows:
ReportViewer 2010 can be used against SQL Server 2008(SP2) and 2012
ReportViewer 2008 can be used against SQL Server 2008 and 2005
ReportViewer 2005 can be used against SQL Server 2005
I found the answer to my problem in this blog:
http://www.orcsweb.com/blog/desiree/access-report-viewer-dll-files-for-your-application/
I just extracted the needed DLL and put it into one of the directories that the webapp was looking for. Still not sure why it happened, though.

Subsonic T4 TextTemplatingService Exception on VS 2005

I have a VS2005 web application I am using the MySQL active record templates and is perfectly working in VS2008 however I get this error:
Custom tool error: An Exception was thrown while running the transformation code. The process cannot continue. The following Exception was thrown:
System.Runtime.Serialization.SerializationException: Type 'Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService' in Assembly 'Microsoft.VisualStudio.TextTemplating.VSHost, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.
View Full Exception Details:
http://pastebin.com/rF8iQJW2
I have the following packages installed to make it work for vs2005:
http://goo.gl/uINkV
Guidance Automation Toolkit for Visual Studio 2005 - February 2008 Release
http://goo.gl/OEUNP
Guidance Automation Extensions - February 2008 Release
Subsonic 3.0 doesn't work for VS2005 as it requires .NET framework 3.5
Previous answer is not correct. The T4 system now runs out of process and sets up an Ipc channel back to the Host. This transport channel ( based on remoting ) uses a Binary serializer and cannot transport the Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService over that channel because it is not marked as serializable, exactly as the exception message says.
Incidently, you can get access to this service by changing the template directive hostspecific="true" and accessing the "Host" property.
There are also some parts of the EnvDTE.DTE that cannot be accessed via T4 templates for the same reason ( like DTE.Windows or DTE.WindowConfiguration ).