BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.SystemException System.Runtime.InteropServices.ComVisible(true)

The following example demonstrates an error that causes a exception.

`using System; class TypeInit { // Static constructor static TypeInit () { // Throw an application-defined exception. throw new ApplicationException("Error in Class TypeInit"); } public TypeInit() {} } class TestTypeInit { static public void Main() { try { TypeInit t = new TypeInit (); } catch (TypeInitializationException e) { Console.WriteLine("Error: {0}",e); } } }`

The output is

`Error: System.TypeInitializationException: The type initializer for "TypeInit" threw an exception. ---> System.ApplicationException: Error in Class TypeInit at TypeInit..cctor() --- End of inner exception stack trace --- at TypeInit..ctor() at TestTypeInit.Main()`

When a class initializer fails to initialize a type, a is created and passed a reference to the exception thrown by the type's class initializer. The property of holds the underlying exception.

uses the HRESULT COR_E_TYPEINITIALIZATION, that has the value 0x80131534.

For a list of initial property values for an instance of , see the constructors.

The exception that is thrown as a wrapper around the exception thrown by the class initializer. This class cannot be inherited.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  An exception that is thrown as a direct result of a previous exception can include a reference to the previous exception in the property. The property returns the same value that is passed into the constructor, or a null reference (Nothing in Visual Basic) if the property does not supply the inner exception value to the constructor.

  The following table shows the initial property values for an instance of .

  Property

  Value

  The inner exception reference.

  The localized error message string.

  The name of the type.

  Initializes a new instance of the class with the default error message, the specified type name, and a reference to the inner exception that is the root cause of this exception.

  The fully qualified name of the type that fails to initialize.
  The exception that is the cause of the current exception. If the parameter is not a null reference (Nothing in Visual Basic), the current exception is raised in a catch block that handles the inner exception.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` To be added.

  Sets the object with the type name and additional exception information.

  The that holds the serialized object data about the exception being thrown. The that contains contextual information about the source or destination.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  A that contains the fully qualified name of the type that caused the exception.

  This property is read-only.

  The property returns the same value as was passed into the constructor.

  Gets the fully qualified name of the type that fails to initialize.

  0
0