BUG: Various errors may occur when you try to call managed code from unmanaged code in Visual C++ .NET 2003

Article translations Article translations
Article ID: 837318 - View products that this article applies to.
Expand all | Collapse all

SYMPTOMS

You have a Microsoft Visual C++ .NET 2003 application that uses multiple application domains. When you try to call managed code from unmanaged code in a DLL that has already been loaded in another application domain, you may receive the following error message:
An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dll
Additional information: Object reference not set to an instance of an object.
Note In some scenarios, you may receive one of the following error messages:
DllNotFoundException

Illegal Instruction

CAUSE

You may notice this problem if your application contains unmanaged code and uses multiple application domains.

For example, if you have an application that uses multiple application domains that use a set of DLLs, you can successfully load and use these DLLs in the first application domain. However, when you try to call the managed code in one of these DLLs from unmanaged code in a different (second) application domain, the behavior that is mentioned in the "Symptoms" section of this article occurs. The application does not load the managed code in the second application domain because the code has already been loaded in another application domain that is in the same process.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section of this article.

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web sites:
Managed Extensions for C++ programming
http://msdn2.microsoft.com/en-us/library/aa712574(vs.71).aspx
Application domains
http://msdn2.microsoft.com/en-us/library/cxk374d9(vs.71).aspx
AppDomain class
http://msdn2.microsoft.com/en-us/library/system.appdomain(vs.71).aspx
NullReferenceException class
http://msdn2.microsoft.com/en-us/library/system.nullreferenceexception(vs.71).aspx

Properties

Article ID: 837318 - Last Review: May 17, 2007 - Revision: 1.6
APPLIES TO
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft .NET Framework 1.1
Keywords: 
kbmanaged kbdll kbprogramming kbinterop kberrmsg kbbug KB837318

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com