BUG: Executing a Visual C++ .NET Assembly from the Current AppDomain Throws a BadImageFormatException (309692)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2002)
  • Microsoft Visual C++ .NET (2003)
  • Microsoft .NET Framework 1.0
  • Microsoft .NET Framework 1.1

This article was previously published under Q309692

SYMPTOMS

An attempt to execute a Visual C++ .NET assembly from an appdomain of another assembly results in a BadImageFormatException.

CAUSE

Visual C++ .NET assemblies can contain unmanaged relocations and unmanaged entries in the Import Address Table. The current version of the Common Language Runtime (CLR) loader is not capable of loading images that contain these unmanaged constructs.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a Managed C++ console application and call it BadImage. Leave the defaults.
  2. Create a Visual C# .NET console application called ClientApp. Add the following code to ClientApp's entry point Main:
    AppDomain dom = AppDomain.CurrentDomain;
    dom.ExecuteAssembly("<Path to BadImage.exe>\\BadImage.exe");
    					
  3. Build the applications and run ClientApp.exe.

    You should see the BadImageFormatException thrown.
NOTE: This only happens when you attempt to execute a Managed C++ assembly.

REFERENCES

For more information, visit the following Microsoft Web site:

Modification Type:MinorLast Reviewed:5/28/2003
Keywords:kbbug kbpending KB309692