.netc++-clic1001

Conversion from char * to System::String gives compiler internal error


I have a string as char *. I need to convert to System::String. After trying various things, I get compiler internal error!

Original code:

char * fileName = "D:\\path1\\path2\\myFile.log";
Console::WriteLine(fileName);

1 First it gives a warning as forcing value to bool 'true' or 'false' (performance warning). I find a solution in {ToString and warning c4800}. It tells me to use something like:

Console::WriteLine(gcnew String((signed char *)fileName, 0, strlen(fileName));

It then gives me this error System::String::String(const wchar_t *, int, int)' : cannot convert parameter 1 from 'signed char *' to 'const wchar_t *'

2 Then I make it simple as:

System::String ^ fileNotFound = gcnew System::String(fileName);
Console::WriteLine(fileNotFound);

I get fatal error C1001: An internal error has occurred in the compiler. And here is the rest of the detail:

(compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c[0x0000000062ECD4AF:0x0000000000000044]', line 182)
 To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++ 
 Help menu, or open the Technical Support help file for more information
LINK : fatal error LNK1000: Internal error during IMAGE::BuildImage
  Version 9.00.30729.01
  ExceptionCode            = C0000005
  ExceptionFlags           = 00000000
  ExceptionAddress         = 0000000062ECD4AF (0000000062DD0000) "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\c2.dll"
  NumberParameters         = 00000002
  ExceptionInformation[ 0] = 0000000000000000
  ExceptionInformation[ 1] = 0000000000000044
CONTEXT:
  Rax    = 0000000000000008  R8     = 0000000004C25338
  Rbx    = 0000000004C25338  R9     = 0000000000000001
  Rcx    = 0000000000000000  R10    = 0000000062DD0000
  Rdx    = 00000000001BDFD0  R11    = 000000006309D7B0
  Rsp    = 00000000001BDEB0  R12    = 0000000000000001
  Rbp    = 0000000005BF0570  E13    = 0000000005C090E0
  Rsi    = 0000000000000000  R14    = 00000000001BDF50
  Rdi    = 0000000004C25338  R15    = 0000000000000000
  Rip    = 0000000062ECD4AF  EFlags = 0000000000010202
  SegCs  = 0000000000000033  SegDs  = 000000000000002B
  SegSs  = 000000000000002B  SegEs  = 000000000000002B
  SegFs  = 0000000000000053  SegGs  = 000000000000002B
  Dr0    = 0000000000000000  Dr3    = 0000000000000000
  Dr1    = 0000000000000000  Dr6    = 0000000000000000
  Dr2    = 0000000000000000  Dr7    = 0000000000000000
Creating browse information file...
Microsoft Browse Information Maintenance Utility Version 9.00.21022
Copyright (C) Microsoft Corporation. All rights reserved.
  1. From the detail, it indicates a file in f: drive! I don't have that hard drive. I think that may refer to the DVD rom?
  2. I have tried to use std::string as type of fileName. Still the same result.

Any help appreciated! Thanks.


Solution

  • I was having another 'internal error' problem. After some research, I come across {Microsoft KB976656}.

    After download and install the {HotFix for KB976656}. I do not see any more of those 'internal error'. Hope this helps other people.