While converting a project that used SlimDX, and therefore has unmanaged code, to .NET 4.0 I ran into the following error:
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.
Googling around gave me the solution, which is to add this to the applications config:
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
My question is, what is the useLegacyV2RuntimeActivationPolicy
doing? I can't find any documentation about it.
After a bit of time (and more searching), I found this blog entry by Jomo Fisher.
So it looks like the way the runtime loads mixed-mode assemblies has changed. I can't find any details about this change, or why it was done. But the
useLegacyV2RuntimeActivationPolicy
attribute reverts back to CLR 2.0 loading.Here's an explanation I wrote recently to help with the void of information on this attribute. http://www.marklio.com/marklio/PermaLink,guid,ecc34c3c-be44-4422-86b7-900900e451f9.aspx (Internet Archive Wayback Machine link)
To quote the most relevant bits:
The full post explains this in more detail. At RTM, the MSDN docs on this should be better.