从char *到System :: String的转换会给编译器内部错误

时间:2014-08-26 06:54:55

标签: .net c++-cli c1001

我有一个字符串char *。我需要转换为System::String。在尝试各种事情后,我得到编译器内部错误!

原始代码:

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

1 首先它会发出警告forcing value to bool 'true' or 'false' (performance warning)。我在{ToString and warning c4800}找到了解决方案。它告诉我使用类似的东西:

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

然后它给了我这个错误System::String::String(const wchar_t *, int, int)' : cannot convert parameter 1 from 'signed char *' to 'const wchar_t *'

2 然后我简单地说:

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

我得到fatal error C1001: An internal error has occurred in the compiler.以下是其余细节:

(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. 从细节上看,它表示f:drive中的文件!我没有那个硬盘。我想这可能是指DVD ROM?
  2. 我尝试使用std::string作为fileName的类型。结果仍然相同。
  3. 任何帮助表示赞赏!感谢。

1 个答案:

答案 0 :(得分:1)

我遇到了另一个“内部错误”问题。经过一些研究,我遇到了{Microsoft KB976656}。

下载并安装{HotFix for KB976656}后。我没有再看到那些“内部错误”。希望这有助于其他人。