Troubleshooting Exceptions: System.NotSupportedException

 

A NotSupportedException exception 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.

Associated Tips

  • Check to make sure the method is supported.
    There are methods that are not supported in the base class, with the expectation that these methods will be supported in the derived classes instead. If a derived class implements only a subset of the methods from its base class, it will throw a NotSupportedException exception for the unsupported methods.

Remarks

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.

  • In such a case, 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.

See Also

NotSupportedException
How to: Use the Exception Assistant