Microsoft KB Archive/873307

= Your application may experience a deadlock condition while loading a mixed DLL in Visual Studio .NET 2002 or Visual Studio .NET 2003 =

Article ID: 873307

Article Last Modified on 5/11/2007

-

APPLIES TO


 * Microsoft Visual C++ .NET 2003 Standard Edition
 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual C++ 2005 Express Edition

-





SYMPTOMS
If you create an application by using Microsoft Visual C++ .NET 2003 or Visual C++ .NET 2002 or Visual C++ 2005, your application may experience a deadlock condition while loading a DLL that contains both managed code and unmanaged code.

Note A DLL that contains both managed code and unmanaged code is known as a mixed DLL.



CAUSE
Because the operating system does not understand managed code and the common language runtime does not understand native code, the operating system and common language runtime must work together to load and to run mixed DLLs. This behavior may create some complications that may cause a deadlock condition.

Note Unmanaged code is also known as native code.

The application may also experience a deadlock condition if the DLL is loaded in the process address space. Frequently, this problem occurs when the system is operating under stress.



MORE INFORMATION
The Microsoft Visual C++ .NET or Visual C++ 2005 compiler can generate both managed code and unmanaged code.

A native DLL contains functions that are implemented in unmanaged code. The versions of the Microsoft Visual C++ compiler that were released before the Visual C++ .NET compiler can generate only native DLLs. The operating system loader loads native DLLs. Native DLLs run directly on the hardware through some operating system intervention.

A managed DLL contains all functions that are implemented in Microsoft intermediate language (MSIL). The common language runtime loader loads managed DLLs. Managed DLLs run on top of the runtime.

A mixed DLL contains at least one function that is implemented in unmanaged code and at least one function that is implemented in MSIL.

When you compile a DLL by using the common language runtime compiler option in Visual C++ .NET 2003 or in Visual C++ .NET 2002 or Visual C++ 2005, the compiler typically generates a mixed DLL. Applications that load these mixed DLLs may experience a deadlock condition that is mentioned in the &quot;Symptoms&quot; section.

