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)

public TypeLoadException(
	string 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.




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.

using System;

public class Example
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
      outputBlock.Text += "This program throws an exception upon successful run." + "\n";
      outputBlock.Text += "Generating TypeLoadException with custom message..." + "\n";
         // Generate a new instance of TypeLoadException.
      catch (TypeLoadException e)
         outputBlock.Text += "TypeLoadException: \n\tError Message = " + e.Message + "\n";
      catch (Exception e)
         outputBlock.Text += "Exception: \n\tError Message = " + e.Message + "\n";

class TypeLoadExceptionDemoClass
   public static bool GenerateException()
      // Throw a TypeLoadException with custom defined message.
      throw new TypeLoadException("This is a custom generated TypeLoadException error message");

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2018 Microsoft