Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
Can anyone help me with this error? It occurs when I try to instantiate a class from a DLL in unsafe mode in VS2010


Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
Posted

Hi,

the DLL is compiled to v2.0.50727 of .NET, your project is .NET 4.0.

you need to set mixed mode assembly in app.config.

XML
<?xml version="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>


With best Regards.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 27-Mar-12 19:42pm    
Correct explanation, my 5; I credited it in my answer, where I also explain the unsafe vs. managed, please see.
--SA
Wonde Tadesse 27-Mar-12 19:49pm    
5+
El_Codero 27-Mar-12 20:03pm    
Thanks for credits and votes! Good addition, important point SA.
In addition to the correct explanation by Björn Ranft:

Unsafe code does not mean unmanaged. In unsafe code, you can pin data and use pointers. It does not make the code unmanaged. C# code is always managed.
Please see:
http://msdn.microsoft.com/en-us/library/chfa2zb8%28v=vs.71%29.aspx[^].

—SA
 
Share this answer
 
Comments
Wonde Tadesse 27-Mar-12 19:49pm    
5+
Sergey Alexandrovich Kryukov 27-Mar-12 21:20pm    
Thank you, Wonde.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900