C# – Downgrade an application from .net 4.0 to 3.5

cnet

I have been developing an application in VS2010 and compiling it for the .NET 4.0 as the target framework. After integrating a library into my application, I get the following error message when I try to compile:

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.

The library works fine under .NET 3.5, but when I change my target framework to .NET 3.5, I get the following error for all my .resx files:

Error 1 Object reference not set to an instance of an object.

I tried ctrl-h Version=4.0.0.0 to Version=3.5.0.0 but that doesn't seem to work. Is there anything I can do other that create a new application?

Best Answer

Open your .resx file with the XML editor instead of the resources editor, and search for System.Windows.Forms, Version=4.0.0.0. There should be 2 instances of this string. Replace 4.0.0.0 with 2.0.0.0 and save the file. Your resources should work correctly now.

Note that you can also go back to .NET 4 and try to add the following to your App.config to allow older assemblies to run on the new runtime:

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