LATEST NEWS

Mixed mode assembly is built against version ‘v2.0.50727’ of the runtime and cannot be loaded in the 4.0 runtime

img
Jun
13

If your application has a dependency on an assembly built in .NET 2 Framework you will see the error below if you try to run your application when it has been built in.NET 4.

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.

I’ve encountered this error while using System.Data.SQLite.dll for my project. Since it was built on .Net 2 framework, it pops out the error.

To fix this, you need to add the useLegacyV2RuntimeActivationPolicy attribute to the application .CONFIG file in the same dir or your app, eg appname.exe.config. The config file should read as follows:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration>

<!-- Add the following tag in your appname.exe.config file -->
  <startup useLegacyV2RuntimeActivationPolicy="true"> 
            <supportedRuntime version="v4.0" />     
  </startup>

  <runtime> 
    <generatePublisherEvidence enabled="false" /> 
  </runtime> 
</configuration>

Well this enables my .Net 4 application to use cross framework assemblies.

Share! Share!
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •