System.Exception.Message Property

Gets a message that describes the current exception.

Syntax

public virtual string Message { get; }

Value

A string that contains a detailed description of the error, or string.Empty. This value is intended to be understood by humans.

Remarks

Error messages target the developer who is handling the exception. The text of the Exception.Message property should completely describe the error and, when possible, should also explain how to correct the error. Top-level exception handlers may display the message to end-users, so you should ensure that it is grammatically correct and that each sentence of the message ends with a period. Do not use question marks or exclamation points. If your application uses localized exception messages, you should ensure that they are accurately translated.

Note:

Do not disclose sensitive information in exception messages without checking for the appropriate permissions.

The value of the Exception.Message property is included in the information returned by Exception.ToString.The Exception.Message property is set only when creating an Exception. If no message was supplied to the constructor for the current instance, the system supplies a default message that is formatted using the current system culture.

Windows Runtime and net_v451

Starting with the net_v451 and win81, the fidelity of error messages from exceptions that are propagated from Windows Runtime types and members that are not part of the .NET Framework is improved. In particular, exception messages from Visual C++ component extensions (C++/CX) are now propagated back into .NET Framework Exception objects.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0