C# – Visual Studio 2010 Can no longer build .NET v3.5

.net-3.5cvisual studio 2010

I have a 2010 project that is targeting .NET v3.5. Inexplicably I can no longer build v3.5 projects. The project doesn't have ANY references added. It won't even let me add a reference to System.Core as it is added by the 'build system'.

warning CS1685: The predefined type 'System.Func' is defined in
multiple assemblies in the global
alias; using definition from
'c:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll'

IFilter.cs(82,49): error CS0433: The type 'System.Func'
exists in both 'c:\Program Files
(x86)\Reference
Assemblies\Microsoft\Framework\v3.5\System.Core.dll'
and
'c:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll'

Looks like something is grabbing onto 4.0 but I'm not quite sure how to fix it. Any one else run into this?

Coworker had this same issue. It took a reinstall of Windows to correct the problem

I've opened a bug on this one: https://connect.microsoft.com/VisualStudio/feedback/details/558245/warning-cs1685-when-compiling-a-v3-5-net-application-in-visual-studio-2010

If the compiler is set to verbose I see this:

FrameworkPathOverride =
C:\Windows\Microsoft.NET\Framework\v4.0.30319

which is defined as:

Specifies the location of mscorlib.dll
and microsoft.visualbasic.dll. This
parameter is equivalent to the
/sdkpath switch of the vbc.exe
compiler.

Some other interesting tidbits: I've created a new project all together and cannot build v3.5 at all. I can build 2.0, 3.0, 3.5 Client Profile, 4.0 and 4.0 Client Profile with no problem. VB.NET can build v3.5 but C# cannot. I've tried a reinstall of .NET 3.5, 4.0 and Visual Studio 2010 with no success. Visual Studio debug logs shown nothing interesting and Safe Mode does not work.

Trying to avoid a Windows reinstall…

EDIT: I've come to realize others are facing this issue as well. Link, Link, Link


Reinstalled several times. Visual Studio uninstalls do not clean up after themselves. I've spun up a VM to develop on until I have a chance to reinstall my main OS.

Best Answer

The problem was the caused by the changes made in this post. Forcing the loading of the latest CLR version is what caused the problem. Be careful!