Upgrading Assembly for new .Net Framework/ Target to a specific .Net Framework
This post describes the process to upgrade an assembly from older .Net versions to newer versions.
- Open the Class Library project in Visual Studio based on newer .Net framework. This will automatically ask for upgrading the project to target it for newer framework. Continue with upgrading it.
- This will upgrade the project to newer framework version. Now rebuild entire solution by going to "Build>Rebuild Solution".
- Check GlobalAssemblyInfo.<.cs or .vb( language extension)>. Ensure that the assembly version number is correctly targeted to newer version:eg. Upgrading assembly to .Net4.0, GlobalAssemblyInfo must have something like:
- Now open project properties for project in which you will include this assembly. Goto "Compile" tab.
- Click on "Advanced Compile Options". Now check the target framework. If it is .Net Framework 4 Client Profile, when you run your project by including that assembly it will throw an exception like: Warning 1 The referenced assembly "
" could not be resolved because it has a dependency on "System.Web, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. test
- Reason behind that your project is target to Framework's client profile. Change the target framework to "All framework" or " .Net Framework 4.0
- Now run the project, it will work fine!