TypeLoadException Constructor (String)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Initializes a new instance of the TypeLoadException class with a specified error message.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- message
- Type: System.String
The message that describes the error.
The content of the message parameter should be understandable to the user. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
The following table shows the initial property values for an instance of TypeLoadException.
Property | Value |
|---|---|
A null reference (Nothing in Visual Basic). | |
The error message string. |
The following code example demonstrates the TypeLoadException(String) constructor. It contains a method that generates a TypeLoadException with a custom message, and displays the error message.
Note: |
|---|
To run this example, see Building examples that have static TextBlock controls for Windows Phone 8. |
Public Class Example Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) outputBlock.Text &= "This program throws an exception upon successful run." & vbCrLf outputBlock.Text &= "Generating TypeLoadException with custom message..." & vbCrLf Try ' Generate a new instance of TypeLoadException. TypeLoadExceptionDemoClass.GenerateException() Catch e As TypeLoadException outputBlock.Text &= ("TypeLoadException: " + ControlChars.Cr + ControlChars.Tab + "Error Message = " + e.Message) & vbCrLf Catch e As Exception outputBlock.Text &= ("Exception: " + ControlChars.Cr + ControlChars.Tab + "Error Message = " + e.Message) & vbCrLf End Try End Sub 'Main End Class 'TypeLoadException_Constructor2 Class TypeLoadExceptionDemoClass Public Shared Function GenerateException() As Boolean ' Throw a TypeLoadException with custom defined message. Throw New TypeLoadException("This is a custom generated TypeLoadException error message") End Function 'GenerateException End Class 'TypeLoadExceptionDemoClass
Note: