What 'additional configuration' is necessary to reference a .NET 2.0 mixed mode assembly in a .NET 4.0 project? What 'additional configuration' is necessary to reference a .NET 2.0 mixed mode assembly in a .NET 4.0 project? sqlite sqlite

What 'additional configuration' is necessary to reference a .NET 2.0 mixed mode assembly in a .NET 4.0 project?


In order to use a CLR 2.0 mixed mode assembly, you need to modify your App.Config file to include:

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

The key is the useLegacyV2RuntimeActivationPolicy flag. This causes the CLR to use the latest version (4.0) to load your mixed mode assembly. Without this, it will not work.

Note that this only matters for mixed mode (C++/CLI) assemblies. You can load all managed CLR 2 assemblies without specifying this in app.config.


This forum post on the .NET Framework Developer Center. It might provide some insight.

(Add to the app's config file.)

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


Depending on what version of the framework you're targeting, you may want to look here to get the correct string:

http://msdn.microsoft.com/en-us/library/ee517334.aspx

I wasted hours trying to figure out why my release targeting .Net 4.0 client required the full version.I used this in the end:

<startup useLegacyV2RuntimeActivationPolicy="true">  <supportedRuntime version="v4.0.30319"                sku=".NETFramework,Version=v4.0,Profile=Client" /></startup>