Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Initialisiert eine neue Instanz der TypeLoadException-Klasse mit einer angegebenen Fehlermeldung und einem Verweis auf die innere Ausnahme, die diese Ausnahme ausgelöst hat.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Sub New ( _
message As String, _
inner As Exception _
)
'Usage
Dim message As String
Dim inner As Exception
Dim instance As New TypeLoadException(message, inner)
public TypeLoadException (
string message,
Exception inner
)
public:
TypeLoadException (
String^ message,
Exception^ inner
)
public TypeLoadException (
String message,
Exception inner
)
public function TypeLoadException (
message : String,
inner : Exception
)
Parameter
- message
Die Fehlermeldung, in der die Ursache der Ausnahme erklärt wird.
- inner
Die Ausnahme, die Ursache der aktuellen Ausnahme ist. Wenn der inner-Parameter kein NULL-Verweis ist (Nothing in Visual Basic), wird die aktuelle Ausnahme in einem catch-Block ausgelöst, der die innere Ausnahme behandelt.
Hinweise
Eine Ausnahme, die als direktes Ergebnis einer vorhergehenden Ausnahme ausgelöst wird, kann in der InnerException-Eigenschaft über einen Verweis auf die vorhergehende Ausnahme verfügen. Die InnerException-Eigenschaft gibt denselben Wert zurück, der an den Konstruktor übergeben wurde, bzw. einen NULL-Verweis (Nothing in Visual Basic), wenn die InnerException-Eigenschaft den Wert der inneren Ausnahme nicht an den Konstruktor übergibt.
In der folgenden Tabelle werden die anfänglichen Eigenschaftenwerte für eine Instanz von TypeLoadException aufgeführt.
Eigenschaft |
Wert |
|---|---|
InnerException |
Der Verweis auf die innere Ausnahme. |
Die Zeichenfolge der Fehlermeldung. |
Beispiel
Imports System
Imports System.Runtime.InteropServices
Public Class TypeLoadException_Constructor3
Public Shared Sub Main()
Console.WriteLine("Calling a method in a non-existent DLL which triggers a TypeLoadException.")
Try
TypeLoadExceptionDemoClass.GenerateException()
Catch e As TypeLoadException
Console.WriteLine(("TypeLoadException: " + ControlChars.Cr + ControlChars.Tab + "Error Message = " + e.Message))
Console.WriteLine(("TypeLoadException: " + ControlChars.Cr + ControlChars.Tab + "InnerException Message = " + e.InnerException.Message))
Catch e As Exception
Console.WriteLine(("Exception: " + ControlChars.Cr + ControlChars.Tab + "Error Message = " + e.Message))
End Try
End Sub 'Main
End Class 'TypeLoadException_Constructor3
Class TypeLoadExceptionDemoClass
' A call to this method will raise a TypeLoadException.
Public Declare Sub NonExistentMethod Lib "NonExistentDLL.DLL" Alias "MethodNotExists" ()
Public Shared Sub GenerateException()
Try
NonExistentMethod()
Catch e As TypeLoadException
' Rethrow exception with the exception as inner exception
Throw New TypeLoadException("This exception was raised due to a call to an invalid method.", e)
End Try
End Sub 'GenerateException
End Class 'TypeLoadExceptionDemoClass
using System;
using System.Runtime.InteropServices;
public class TypeLoadException_Constructor3
{
public static void Main()
{
Console.WriteLine("Calling a method in a non-existent DLL which triggers a TypeLoadException.");
try
{
TypeLoadExceptionDemoClass.GenerateException();
}
catch (TypeLoadException e)
{
Console.WriteLine ("TypeLoadException: \n\tError Message = " + e.Message);
Console.WriteLine ("TypeLoadException: \n\tInnerException Message = " + e.InnerException.Message );
}
catch (Exception e)
{
Console.WriteLine ("Exception: \n\tError Message = " + e.Message);
}
}
}
class TypeLoadExceptionDemoClass
{
// A call to this method will raise a TypeLoadException.
[DllImport("NonExistentDLL.DLL", EntryPoint="MethodNotExists")]
public static extern void NonExistentMethod();
public static void GenerateException()
{
try
{
NonExistentMethod();
}
catch (TypeLoadException e)
{
// Rethrow exception with the exception as inner exception
throw new TypeLoadException("This exception was raised due to a call to an invalid method.", e);
}
}
}
using namespace System;
using namespace System::Runtime::InteropServices;
ref class TypeLoadExceptionDemoClass
{
public:
// A call to this method will raise a TypeLoadException.
[DllImport("NonExistentDLL.DLL",EntryPoint="MethodNotExists")]
static void NonExistentMethod();
static void GenerateException()
{
try
{
NonExistentMethod();
}
catch ( TypeLoadException^ e )
{
// Rethrow exception with the exception as inner exception
throw gcnew TypeLoadException( "This exception was raised due to a call to an invalid method.",e );
}
}
};
int main()
{
Console::WriteLine( "Calling a method in a non-existent DLL which triggers a TypeLoadException." );
try
{
TypeLoadExceptionDemoClass::GenerateException();
}
catch ( TypeLoadException^ e )
{
Console::WriteLine( "TypeLoadException: \n\tError Message = {0}", e->Message );
Console::WriteLine( "TypeLoadException: \n\tInnerException Message = {0}", e->InnerException->Message );
}
catch ( Exception^ e )
{
Console::WriteLine( "Exception: \n\tError Message = {0}", e->Message );
}
}
import System.*;
import System.Runtime.InteropServices.*;
public class TypeLoadException_Constructor3
{
public static void main(String[] args)
{
Console.WriteLine("Calling a method in a non-existent DLL which"
+" triggers a TypeLoadException.");
try {
TypeLoadExceptionDemoClass.GenerateException();
}
catch (TypeLoadException e) {
Console.WriteLine("TypeLoadException: \n\tError Message = "
+ e.get_Message());
Console.WriteLine("TypeLoadException: \n\tInnerException Message = "
+ e.get_InnerException().get_Message());
}
catch (System.Exception e) {
Console.WriteLine("Exception: \n\tError Message = "
+ e.get_Message());
}
} //main
} //TypeLoadException_Constructor3
class TypeLoadExceptionDemoClass
{
// A call to this method will raise a TypeLoadException.
/** @attribute DllImport("NonExistentDLL.DLL", EntryPoint =
"MethodNotExists")
*/
public static native void NonExistentMethod();
public static void GenerateException()
{
try {
NonExistentMethod();
}
catch (TypeLoadException e) {
// Rethrow exception with the exception as inner exception
throw new TypeLoadException("This exception was raised due to a "
+"call to an invalid method.", e);
}
} //GenerateException
} //TypeLoadExceptionDemoClass
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
TypeLoadException-Klasse
TypeLoadException-Member
System-Namespace
Exception-Klasse