48
votes

i've included a directX player in c# .net 4.0 app that is included here ( answer2 ) . The problem is that when i try to initialize the object ( i.e. Player mPlayer=new Player()) this error occurs :

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

Anyone knows what it can be?

3
IMPORTANT: If the error happens with error column "File" as SGEN, then the fix needs to be in a file sgen.exe.config, next to sgen.exe. For example, for VS 2015, create C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\sgen.exe.config. Source: SGEN Mixed mode assembly Minimum file contents: <configuration><startup useLegacyV2RuntimeActivationPolicy="true"/></configuration>ToolmakerSteve

3 Answers

70
votes

You need to add an app.Config file and set useLegacyV2RuntimeActivationPolicy to true.

This is required to use mixed mode CLR 2 assemblies in a .NET 4 application.

72
votes

The way I fixed this error was by changing the 'configuration' node on my app.config from this:

<startup>
   <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>

to this:

<startup useLegacyV2RuntimeActivationPolicy="true">
   <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
3
votes

Here is possible assembly configuration:

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