views:

882

answers:

3

Has anyone had any success converting a VS 2008 C++/CLI (vcproj) project to a VS 2010 project (vcxproj), whilst maintaining .NET 3.5 as the target framework? I haven't been able to do this and get the project to build successfully. The project compiles fine in VS2008 as .NET 3.5, and fine in VS2010 as .NET 4.0, but I am unable to target .NET 3.5 in 2010. The IDE doesn't seem to provide an option for it, and modifying the vcxproj file by adding

<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>

causes compilation to fail with the folling error:

Error   1   error C1001: An internal error has occurred in the compiler.

According to this link, there is apparently some differences in compilers used between VS2008 and 2010, but manually editing the project file was still suggested as a solution. Does anyone have any idea on this?

A: 

Thanks for the tip on TargetFrameworkVersion. It worked for me, but this unfortunately does not help you.

It is easy to get "internal compiler error" if you have some old files (PCH files, object files) made for another version of the C++ compiler lying around. Have you cleaned everything when you changed tools version?

Arve
Ah thanks for the reply, I'll have to have a look at work. This was an issue with a C++/CLI portion of a primarily .NET project so I simply compiled it in 2008 and referenced via DLL reference rather than project. We ended up not using it anyway, but I shall check and see if that fixes it
jeffora
Marking this as answer due to not being able to reproduce the problem (or rather not needing the situation that was causing the problem anymore)
jeffora
+3  A: 

When you're targeting .Net framework v3.5 and building using VS2010 you can sometimes trigger the linker error C1001 due to VS2010 automatically adding a reference to System.Core when you're compiling. This isn't explicit and will not show up in your references but rather done during compile time. You can tell VS to not add the assemblies by adding this element in your Globals PropertyGroup:

<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
Kevin McMahon
I have tried your solution to C1001. Now the entire Visual Studio 2010 (final release) crashes. Any solutions?
brickner
Opened a bug report on Microsoft Connect:https://connect.microsoft.com/VisualStudio/feedback/details/560606/c1001-compiler-crash-on-c-cli-project-in-vs2010-when-target-framework-is-3-5
brickner
Did you verify that the reference to the .net fx 4.0 assemblies were removed? You can see what is getting called via the command line and what assemblies are being included. I had to do this to two different projects and the first one worked like a charm and for some reason the second took a while (closing the solution and VS and reopening I think did the trick) to finally remove the reference.
Kevin McMahon
Nice; adding this property fixed the internal compiler error for me (I restarted VS to avoid anything being cached). It removes the /FU(...)\v3.5\System.Core.dll argument to the compiler. Any reason why no-one's added this as a workaround in the Connect bug?
voyce
After running into exactly the same issue I just added the workaround on the connect page with a link here. Hopefully VS2010 doesn't crash on me any more!
Eric Nicholson
+1  A: 

Wow, the response to Brickner's bug report is devastating - targeting 3.5 is not supported and won't be fixed!

My own weird experiences with crashes are that they were fixed by turning on precompiled headers, even more strange because stdafx.h was empty so I don't know what they are doing.

Andy Dent