A type DLL cannot be added to type B DLL. Type A arises .. from the context of LoadFrom

I am trying to test the third pary API in visual studio using TestProject. I get an error. I refer to the third API in the test project, as well as in the business logic. Now I pass the test data from the test project project to the business logic, having received the following error.

[A] TIMSS.API.User.UserDefinedInfo.UserDefinedCustomerTechnicalDisciplinees cannot be attributed to [B] TIMSS.API.User.UserDefinedInfo.UserDefinedCustomerTechnicalDisciplinees. Type A is taken from "TIMSS.API.User, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null" in the context of "LoadFrom" at the location "C: \ Svad \ Trunk \ Source \ EBusiness \ EBusiness.Test \ bin \ Bin \ TIMSS.API.User.dll. Type B is derived from "TIMSS.API.User, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null" in the "Default" context at the location "C: \ Svadlakonda \ Srikanth \ Trunk \ Source \ EBusiness \ EBusiness.Test \ Bin \ TIMSS.API.User.dll ".

What is the problem? I tried to make a DLL with a test project using the link to Copy Localbefore falseand vice versa did not work.

+4
source share
4 answers

Assuming the types are actually the same (or cast) in both assemblies (the one referenced by the project and the one loaded using LoadFrom), loading the "LoadFrom" assembly into the application domain should fix the problem. This is probably not thread safe, but worth a try.

// This can cause "A cannot be cast to B" errors even using two exact copies of the same DLL.
var uncastableAssembly = Assembly.LoadFrom(filename);

// This shoud solve the casting issue but there still could be other issues.
var castableAssembly = AppDomain.CurrentDomain.Load(Assembly.LoadFrom(filename).GetName());
+2
source

I had this error, and the only thing that was fixed was the installation of Microsoft.NET Framework 4.5.2 (Offline Installer)    https://www.microsoft.com/en-us/download/details.aspx?id=42642

SQL Server 2014 , msxml 6.0.

messsage :

[A] xx.xxxx.ClassUserDS [B] xx.xxxx.ClassUserDS. A "yyyyyy", "Version = 3.0.5617.31787", "Culture = neutral", "PublicKeyToken = 657d68e01eb7c911" " " "C:\Users\xxxxx\Appdata\Local\assembly\dl3\QQ3VBMNC.EO1\VYVECOB7.H5J\2b6c89d2\51158eea_9892d001\yyyyyy.DLL. B orginates 'yyyyyy, Version = 3.0.5617.31787' " LoadNeither " " C:\Users\xxxxx\Appdata\Local\Microsoft\InfoPath\FormCache4\30083E69.D18\cd264661b1055c58 $b04f2786908cb791\yyyyyy.dll

regedit HKCU\Software\Microsoft\Fusion \, .

, .

C:\Program Files (x86)\Microsoft Office\Office15\INFOPATH.EXE /cache clearall

or 64bit office 2013:
C:\Program Files\Microsoft Office\Office15\INFOPATH.EXE /cache clearall

or 64bit office 2010
C:\Program Files\Microsoft Office\Office14\INFOPATH.EXE /cache clearall

fusion (GAC), , ( ".NET Framework 1.1 Configuration" "", .)

0

:

(4.5.2) , ( 4.6.1)

0

, aspx, .

tutorials.aspx tutorials-hidden.aspx. , URL-, 500. tutorials.aspx, . , csproj .

0

All Articles