TypeLoadException::Message Property


Gets the error message for this exception.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

property String^ Message {
	virtual String^ get() override;

Property Value

Type: System::String^

The error message string.

This property overrides Message. The error message should be localized.

This property is read-only.

The following example attempts to load a non-existent type from the mscorlib assembly. The resulting exception is caught, and the TypeName and Message values are displayed. For this code example to run, you must provide the fully qualified assembly name. For information about how to obtain the fully qualified assembly name, see Assembly Names.

// Load the mscorlib assembly and get a reference to it.
// You must supply the fully qualified assembly name for mscorlib.dll here.
Assembly^ myAssembly = Assembly::Load( "Assembly text name, Version, Culture, PublicKeyToken" );
   Console::WriteLine( "This program throws an exception upon successful run." );

   // Attempt to load a non-existent type from an assembly. 
   Type^ myType = myAssembly->GetType( "System.NonExistentType", true );
catch ( TypeLoadException^ e ) 
   // Display the name of the Type that was not found.
   Console::WriteLine( "TypeLoadException: \n\tError loading the type '{0}' from the assembly 'mscorlib'", e->TypeName );
   Console::WriteLine( "\tError Message = {0}", e->Message );
catch ( Exception^ e ) 
   Console::WriteLine( "Exception: Error Message = {0}", e->Message );

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top