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?

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.

Mixed mode assembly is built against version '2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime

Working with Bling for DirectX 10.0, (Bling UI Toolkit at CodePlex). I got the error that ended me up here on this page looking for the solution, the app.config file in the D3D10.example included the supported runtime, version=4 line. But it does NOT include a later line for the version=2 .net line, using the app.config as:

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

solved the problem, and all examples run in VS2012 once the config file is modified to the code shown.

I don't know if this post is to late for an answer, I'm just starting in windows 7 and VS2012 this month on a graphics project and the config change solved my problem.

What happens when .NET 4.0 references a .NET 2.0 assembly?

They say it should work fine. Check out this.

Mixed mode assembly is built against old version of the runtime and cannot be loaded without additional configuration

Just solved it try this:

  1. Make sure that if you have more than one project they are all set to build for .net 4 full not client.
  2. If you keep getting the compiler error set the "Generate serialization assembly" to OFF
  3. If you are building a plug-in and the output of your project is a dll you have to create a config file for that program (i had to create "INFOPATH.EXE.config")

Hope it helps

.net 4 Application running a .net 2.0 assembly

It's called mixed-mode, and you can do it by setting/changing some properties in app.config file, eg.:

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

Mixed mode assembly in .NET 4

The best would probably be to recompile your class library for .NET 4.0 in Visual Studio 2010 (ie. opening up the project, converting it, and changing the target framework.)

If you can't, or won't, do that, then you can try adding the following to your app.config file for your .NET 4.0 application:

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

ie.

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


Related Topics



Leave a reply



Submit