Sunday, January 22, 2012

.NET Framework Mixed mode assembly loading error "Cannot be loaded in x.x runtime without additional configuration"

Problem:


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.


Reason:


You are using an assembly reference (or a DLL) which was build in old version of .NET framework than the one your application is built on.


Workaround:


There are 2 possible solutions:



  1. You can revert back you application's Target Framework by going to project properties. Choose the framework in which the reference assembly or DLL is built e.g. ( 2.0). 


Now you need to rebuild your project.

2. Second Solution, which is better than above that you need to modify your project's app.config file. (if it exists in you project). If app.config file does not exist in your project, add it manually to your project by Add --> New Item --> General --> Application Configuration File.
Now modify it by addting this xml node into <configuration> node:

 <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0"/>
 </startup>

So it would now look like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0"/>
    </startup>
</configuration>






Now rebuild your project. Hopefully it would work great.

No comments:

Post a Comment