Why is the Target Framework dropdown empty and gre

2020-02-11 04:58发布

问题:

Fairly self-explanatory. I have recently installed .NET framework 4 and VS2010 but I want to compile my 3.5 projects using 3.5 as 4 has not yet been installed on our production servers and I get "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded." if I try

All project types have the target framework dropdown greyed out

回答1:

Make sure that your registry keys:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\OnlyUseLatestCLR

and

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\OnlyUseLatestCLR

are set to 0 (not 1).

This fixed it for me since applications like VS2008 are no longer forced to use .NET 4.0 runtime. I had previously set these registry keys to allow Powershell run inder .NET 4.0, however, a config file should be used for that instead.



回答2:

This has something to do with .NET 2.0 assemblies (i.e. mscorlib) being removed from GAC.

I managed to fix this by first uninstalling .NET framework 3.5 and 4.0 from my Windows 7 using .NET framework cleanup tool:

http://blogs.msdn.com/b/astebner/archive/2008/08/28/8904493.aspx

And then reinstalling both frameworks (first 3.5, then 4.0) from the web. Now the drop-down has options again in VS2008 and I can multi-target 3.5 framework from VS2010.