Mono Class Library: System NamespaceSystem.BadImageFormatException Class |
See Also: BadImageFormatException Members
System.Object
System.Exception
System.SystemException
System.BadImageFormatException
|
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
This exception is thrown when the file image of an executable program is invalid. For example, this exception is thrown when unmanaged code is passed to System.Reflection.Assembly.Load(string) for loading. [Edit]
The following example demonstrates an attempt to load an unmanaged executable, which causes the system to throw a BadImageFormatException exception.
Note: The name of the unmanaged executable is "calc".
C# Example using System; using System.Reflection; public class BadImageExample { public static void Main() { try { Assembly a = Assembly.Load("calc"); } catch (BadImageFormatException e) { Console.WriteLine("Caught: {0}", e.Message); } } }The output is
Caught: The format of the file 'calc' is invalid.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0