RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.
You attempt to compile a Visual C++ 7.1 mixed-mode program in which an ANSIÂ string literal is passed to a function where a System::String is expected, and this is passed on to a function with variable arguments (,...).
For instance, suppose you have a function that resembles this:
void MyFunction( System::String * pText )
{
    ATLTRACE("MyFunction called with %s\n", pText);
    \\ Do something else
    return;
}
and you may call it with something like this:
MyFunction("Here is an ANSI string literal");
You may get an Internal Compiler Error similar to this:
C:\Program Files\Microsoft Visual Studio .NET 2003\vc7\atlmfc\include\atltrace.h(167) : fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'f:\vs70builds\3077\vc\Compiler\Utc\src\P2\imeta.cpp', line 548)
In VC++ 7.1 (and .NET 1.1), when an ANSI string literal is passed to a function expecting a System::String *, the compiler has to perform a conversion to generate the String*.
If that String* parameter is passed to a variable argument function (such as the one from the ATLTRACE macro), the compiler has to generate special code to make that happen, because vararg functions are a complex special case. To do this, the compiler uses APIs from the Common Language Runtime. The compiler and the CLR communicate via metadata tokens. In some cases, the CLR API may fail if it doesn't recognize a token that the compiler has used previously. The VC++ 7.1 compiler did not properly handle this API failure, and consequently failed with an ICE.
This problem is fixed in Visual Studio 2005 and .NET Framework 2.0. Numerous improvements have been made to the compilers and .NET Frameworks, including much better interoperability between native and managed code (C++/CLI), and handling of loader locks, just to name a couple. The recommended resolution would be to upgrade to Visual Studio 2005 or later (such as VS 2008).
If you must stay with VC++ 7.1, the simplest solution is to pass a string literal that is a .NET string (System::String) instead of an ANSI string (char *). To do this, simply prefix the string with 'S':
MyFunction(S"Here is a .NET string literal");
Alternatively, you could make sure that your string is properly converted to an intermediate String variable before passing to a vararg function, or just avoid using vararg functions with .NET types.
MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALSâ€) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.