VS 2010 Compiler Error
-
Sunday, January 02, 2011 8:48 PM
Just converted a C++ project to Visual Studio 2010 and followed the instructions to set the TargetFramework to 3.5. When trying to compile the project, I get this error:
1> (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c[0x58BDE0DB:0x00000030]', line 182)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1> Please choose the Technical Support command on the Visual C++
Tracked it down in the C++ code to this code:
char* orig = "Hello World!";
String^ newString =
gcnew String (orig);
It appears that this code works fine when 4.0 is the target, but when the target is 3.5, the compiler always throws an error. By the way, the following code has no problem:String^ newString =
gcnew String ("Hello World!");
Any suggestions? Looks like a compiler bug to me when 3.5 is the target framework in visual studio 2010.
All Replies
-
Sunday, January 02, 2011 10:39 PMHi phb314
Apparently there is some problem.
Try to post to https://connect.microsoft.com/VisualStudio/feedback
or "choose the Technical Support command on the Visual C++" -
Sunday, January 02, 2011 11:06 PM
Right, the code examples didn't paste correctly. I've re-done it here.
The one that doesn't work is:
char *orig = "Hello World!"; String^ newString = gcnew String (orig);
But, if you just have this, it works fine:
The first example should work correctly. For me, it works in Visual Studio 2008 on the same machine. It does not work on Visual Studio 2010 targeted to the 3.5 framework on the same machine. It does work on Visual Studio 2010 targeted to the 4.0 framework.String^ newString = gcnew String ("Hello World!"); -
Monday, January 03, 2011 2:59 AM
Right, the code examples didn't paste correctly. I've re-done it here.
Does it make any difference if (as you should) you write
The one that doesn't work is:
char *orig = "Hello World!";
String^ newString = gcnew String (orig);
But, if you just have this, it works fine:
String^ newString = gcnew String ("Hello World!");
The first example should work correctly. For me, it works in Visual Studio 2008 on the same machine. It does not work on Visual Studio 2010 targeted to the 3.5 framework on the same machine. It does work on Visual Studio 2010 targeted to the 4.0 framework.
const char *orig = "Hello World!";
String^ newString = gcnew String (orig);
or
const wchar_t *orig = L"Hello World!";
String^ newString = gcnew String (orig);
David Wilkinson | Visual C++ MVP -
Monday, January 03, 2011 3:47 AMModerator
Hi phb314,
It seems to be a known issue about String in .Net 3.5 which we can reproduce it by adding reference System.Core and turn off the precompiled header. For more information, you can see https://connect.microsoft.com/VisualStudio/feedback/details/629060/compiler-crash-related-to-system-core-and-string.
If it is the case on your side, the problem comes from c1xx.dll. Our engineer verified an updated c1xx.dll will fix this problem. So far, we also confirmed that the problem will be fixed if we install the hotfix at http://support.microsoft.com/kb/976656.
Hope this information helps.
Regards,
Yi Feng Li
Yi Feng Li [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

- Marked As Answer by Paul Brosche Wednesday, January 05, 2011 7:11 AM
-
Tuesday, January 04, 2011 3:47 AM
Thanks guys for the responses.
Dave, that didn't make a difference. I had tried all sorts of different syntax with the same results.
Yi, I didn't get a chance to try yours.
What I did was create a brand new project in 2010 and targeted it to 3.5 and then manually added all of the source files to the new project. The compiler errors stopped occurring. Didn't find the root cause, but for my purposes, the problem is gone.
Thanks for the help.
-
Tuesday, January 04, 2011 3:53 AMModerator
Hi phb314,
We are glad to know this issue is solved.
Cheers,
Yi Feng Li
Yi Feng Li [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

-
Wednesday, January 05, 2011 7:11 AM
Yi,
I just wanted to follow up on this. It turns out that I was incorrect. The new project was still targeting the 4.0 framework which is why it was compiling successfully. I realized this today when I attempted to reference it from a 3.5 .NET assembly and it complained. After I set the target to 3.5, the error started occurring again.
Therefore, I came back here to the hotfix that you recommended and installed it. The hotfix did solve the root problem and everything is building and running now. I just thought I should let you know.
Thank you very much for the answer. I would've been spinning my wheels for a while without it.
Cheers,
Paul

