Easiest way to convert a .NET project from 4.5 to 4.0?

I have a .NET application that I built in version 4.5, which has links to a bunch of libraries that were built in 4.5, which themselves have links to 4.5, etc. The user group that I am trying to distribute as an application to problems with running the executable file, since they are installed on 4.0; in particular, they get a MissingMethodException:

Method not found: 'System.Type System.Runtime.InteropServices.Marshal.GetTypeFromCLSID(System.Guid)'. 

Since we may have a problem upgrading each user to 4.5 (since none of them have administrator rights on their computers, and this will require a separate update request for each user), I'm looking for a simple way to rebuild project 4.0. This seems to require me to rebuild every library and libraries it refers to in 4.0; is there an easier way to do this than go through each library one by one and create version 4.0? I think maybe this is a one-click option for "Rebuild all libraries referenced in the target structure" or something like that.

+6
source share
4 answers

If you have dependencies on .Net 4.5 DLLs, you will also need to get .Net 4.0 versions if you want to successfully downgrade your project. The .Net project can only reference .Net DLLs to the same .Net version as the link assembly.

The easiest way to do this is to use something like NuGet to manage your dependencies. Please note that when changing the target version of your project in VS, you will need to remove and reinstall the dependencies using NuGet, since NuGet will not automatically do this for you when changing the target version of the frame.

Of course, if all the dependencies relate to your own code, and you do not publish it through a dependency management system such as NuGet, you will also need to downgrade all your other code to .Net 4.0

+4
source

When I use Visual Studio, I right-click on the project, change the structure, fix the links and recompile. Usually straight ahead.

+4
source

Please see this MSDN page to redirect the project to the lower target structure without any problems! This is a bit outdated in terms of versions, but the same process is described!

+1
source

This is based on my experience. I had an application originally created in the .NET Framework 4.5, but I wanted to convert it to the .NET Framework 4.0. I created a new project from the originally created 4.0, and then I copied and pasted all the forms and controls of my previous application, and it works. Framework 4.5 uses Aero2, and 4.0 uses Aero ... Good luck :)

0
source

All Articles