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



The information in this article applies to:

  • Microsoft Visual C++ .NET (2003)
  • Microsoft Visual C++ .NET (2002)
  • 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 "Symptoms" section.

REFERENCES

For more information about the mixed DLL loading problem, visit the following Microsoft Developer Network (MSDN) Web site: For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

814472 Linker warnings when you build Managed Extensions for C++ DLL projects


Modification Type:MajorLast Reviewed:1/16/2006
Keywords:kbManaged kbtshoot kbDLL kbprb KB873307 kbAudDeveloper