I had a requirement to use a .NET dll assembly that was built against version 'v2.0.50727'to reference to it in my .Net Framework 4.0 windows forms application.

After referencing the dll, compilation error occurred in the application - "are you missing a using directive or an assembly reference."

Reason: As the DLL is a CLR 2.0 runtime assembly, it cannot be loaded in the 4.0 runtime.


You will need to set useLegacyV2RuntimeActivationPolicy to true in app.config file. This is required to use mixed mode CLR 2 assemblies(targeting version 2.0.50727 of the CLR), in a .NET 4 application.

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

0 Responses to How To Use a .NET 2.0 Runtime DLL From .NET 4.0 Windows Forms application?

Post a Comment