Microsoft KB Archive/309692

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

Article ID: 309692

Article Last Modified on 2/23/2007

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual C++ .NET 2003 Standard Edition
 * 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.



Steps to Reproduce the Behavior
 Create a Managed C++ console application and call it BadImage. Leave the defaults.  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(&quot;\\BadImage.exe&quot;);  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.

