TypeLoadException Constructor (String)
Collapse the table of content
Expand the table of content

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.

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

'Declaration
Public Sub New ( _
	message As String _
)

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

InnerException

A null reference (Nothing in Visual Basic).

Message

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.



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


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft