Microsoft KB Archive/327434

= BUG: Mscorwks.dll does not initialize =

Article ID: 327434

Article Last Modified on 8/25/2005

-

APPLIES TO


 * Microsoft Visual Studio .NET 2002 Professional Edition

-



This article was previously published under Q327434



SYMPTOMS
When you run an unmanaged application that links to a managed DLL, you receive the following error message in a Microsoft .NET Framework Initialization Error dialog box:

C:\Windows\Microsoft.Net\Framework\v1.0.3705\mscorwks.dll cannot be loaded.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to Reproduce the Behavior
  Use the following code to create a file named 1.cpp: //1.cpp (unmanaged) __declspec(dllimport) int Func2;

int g_1 = 0;

__declspec(dllexport) int Func1 { return (g_1 + Func2); }                     Use the following code to create a file named 2.cpp: // 2.cpp (managed) int g_2 = 0;

__declspec(dllexport) int Func2 { return (g_2 + 2); }                     Use the following code to create a file named Main.cpp: //main.cpp __declspec(dllimport) int Func1; __declspec(dllimport) int Func2;

int main { return ( Func1 + Func2 ); }                     Compile 2.cpp to a managed DLL: cl /clr /LD 2.cpp   Compile 1.cpp to an unmanaged DLL with the /MD command as follows (this links with the multi-threaded DLL version of the C runtime): cl /MD /LD 1.cpp /link 2.lib   Compile Main.cpp to an unmanaged executable (.exe) file: cl main.cpp /link 1.lib 2.lib </li> Run Main.exe. When Main.exe is run, the operating system loads 1.dll. 1.dll has a dependency on 2.dll, so 2.dll is loaded. 2.dll starts the Microsoft .NET runtime, which causes malloc to be called. The call to malloc is not successful because the C runtime has not been initialized yet. The C runtime has not been initialized because 1.dll has a reference to it (which prevents 2.dll from initializing it.)</li></ol>

Additional query words: mscorwks initilization

Keywords: kbbug kbvs2002sp1sweep KB327434

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.