NotSupportedException Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

The exception that is thrown when an invoked method is not supported, or when there is an attempt to read, seek, or write to a stream that does not support the invoked functionality.

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


type NotSupportedException = 
        inherit SystemException


Initializes a new instance of the NotSupportedException class, setting the Message property of the new instance to a system-supplied message that describes the error. This message takes into account the current system culture.

System_CAPS_protmethodNotSupportedException(SerializationInfo, StreamingContext)

Initializes a new instance of the NotSupportedException class with serialized data.


Initializes a new instance of the NotSupportedException class with a specified error message.

System_CAPS_pubmethodNotSupportedException(String, Exception)

Initializes a new instance of the NotSupportedException class with a specified error message and a reference to the inner exception that is the cause of this exception.


Gets a collection of key/value pairs that provide additional user-defined information about the exception.(Inherited from Exception.)


Gets or sets a link to the help file associated with this exception.(Inherited from Exception.)


Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.(Inherited from Exception.)


Gets the Exception instance that caused the current exception.(Inherited from Exception.)


Gets a message that describes the current exception.(Inherited from Exception.)


Gets or sets the name of the application or the object that causes the error.(Inherited from Exception.)


Gets a string representation of the immediate frames on the call stack.(Inherited from Exception.)


Gets the method that throws the current exception.(Inherited from Exception.)


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.(Inherited from Exception.)


Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetObjectData(SerializationInfo, StreamingContext)

When overridden in a derived class, sets the SerializationInfo with information about the exception.(Inherited from Exception.)


Gets the runtime type of the current instance.(Inherited from Exception.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Creates and returns a string representation of the current exception.(Inherited from Exception.)


Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.(Inherited from Exception.)

NotSupportedException indicates that no implementation exists for an invoked method or property.

NotSupportedException uses the HRESULT COR_E_NOTSUPPORTED, which has the value 0x80131515.

For a list of initial property values for an instance of NotSupportedException, see the NotSupportedException constructors.

You might consider throwing a NotSupportedException exception in the following cases:

  • You are implementing a general-purpose interface, and number of the methods have no meaningful implementation. For example, if you are creating a date and time type that implements the IConvertible interface, you would throw a NotSupportedException exception for most of the conversions.

  • You've inherited from an abstract class that requires that you override a number of methods. However, you're only prepared to provide an implementation for a subset of these. For the methods that you decide not to implement, you can choose to throw a NotSupportedException.

  • You are defining a general-purpose type with a state that enables operations conditionally. For example, your type can be either read-only or read-write. In that case:

    • If the object is read-only, attempting to assign values to the properties of an instance or call methods that modify instance state should throw a NotSupportedException exception.

    • You should implement a property that returns a Boolean value that indicates whether particular functionality is available. For example, for a type that can be either read-only or read-write, you could implement a IsReadOnly property that indicates whether the set of read-write methods are available or unavailable.

The NotSupportedException exception indicates that a method has no implementation and that you should not call it. You should not handle the exception. Instead, what you should do depends on the cause of the exception: whether an implementation is completely absent , or the member invocation is inconsistent with the purpose of an object (such as a call to the FileStream.Read method on a read-only FileStream object .

An implementation has not been provided because the operation cannot be performed in a meaningful way.

This is a common exception when you are calling methods on an object that provides implementations for the methods of an abstract base class, or that implements a general-purpose interface, and the method has no meaningful implementation.

For example, the Convert class implements the IConvertible interface, which means that it must include a method to convert every primitive type to every other primitive type. Many of those conversions, however, are not possible. As a result, a call to the Convert.ToBoolean(DateTime) method, for instance, throws a NotSupportedException exception because there is no possible conversion between a DateTime and a Boolean value

To eliminate the exception, you should eliminate the method call.

The method call is not supported given the state of the object.

You are attempting to invoke a member whose functionality is unavailable because of the object's state. You can eliminate the exception in one of three ways:

  • You know the state of the object in advance, but you've invoked an unsupported method or property. In this case, the member invocation is an error, and you can eliminate it.

  • You know the state of the object in advance (usually because your code has instantiated it), but the object is mis-configured. The following example illustrates this issue. It creates a read-only FileStream object and then attempts to write to it.

    No code example is currently available or this language may not be supported.

    You can eliminate the exception by ensuring that the instantiated object supports the functionality you intend. The following example addresses the problem of the read-only FileStream object by providing the correct arguments to the FileStream.FileStream(String, FileMode, FileAccess) constructor.

  • You don't know the state of the object in advance, and the object doesn't support a particular operation. In most cases, the object should include a property or method that indicates whether it supports a particular set of operations. You can eliminate the exception by checking the value of the object and invoking the member only if appropriate.

    The following example defines a DetectEncoding method that throws a NotSupportedException exception when it attempts to read from the beginning of a stream that does not support read access.

    No code example is currently available or this language may not be supported.

    You can eliminate the exception by examining the value of the FileStream.CanRead property and exiting the method if the stream is read-only.

    No code example is currently available or this language may not be supported.

The NotSupportedException exception is closely related to two other exception types;


This exception is thrown when a method could be implemented but is not, either because the member will be implemented in a later version, the member is not available on a particular platform, or the member belongs to an abstract class and a derived class must provide an implementation.


This exception is thrown in scenarios in which it is generally sometimes possible for the object to perform the requested operation, and the object state determines whether the operation can be performed.

When working with the .NET Compact Framework and using P/Invoke on a native function, this exception may be thrown if:

  • The declaration in managed code is incorrect.

  • The .NET Compact Framework does not support what you are trying to do.

  • The DLL names are mangled on export.

If a NotSupportedException exception is thrown, check:

  • For any violations of the .NET Compact Framework P/Invoke restrictions.

  • For any arguments that require pre-allocated memory. If these exist, you should pass a reference to an existing variable.

  • That the names of the exported functions are correct. This can be verified with DumpBin.exe.

  • That you are not attempting to pass too many arguments.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top