TypeLoadException::TypeName Property


Gets the fully qualified name of the type that causes the exception.

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

property String^ TypeName {
	String^ get();

Property Value

Type: System::String^

The fully qualified type name.

Notes to Inheritors:

When overriding TypeName in a derived class, be sure to call the base class's TypeName property.

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
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top