SEHException Class
Updated: March 2009
Represents Structured Exception Handler (SEH) errors.
Assembly: mscorlib (in mscorlib.dll)
The SEHException class handles SEH errors that are thrown from unmanaged code, but that have not been mapped to another .NET Framework exception. The SEHException class also responds to the HRESULT E_FAIL, which has the value 0x80004005.
The .NET Framework often encounters unmanaged SEH exceptions that are automatically mapped to managed equivalents. There are two common unmanaged SEH exceptions:
STATUS_NO_MEMORY exceptions are automatically mapped to the OutOfMemoryException class.
STATUS_ACCESS_VIOLATION exceptions are automatically mapped as follows:
If legacyNullReferencePolicy is applied, all access violations are mapped to the NullReferenceException class.
If the address at which the read/write was attempted is not in JIT-compiled code, the exception is mapped to the AccessViolationException class.
If the address at which the read/write was attempted is in JIT-compiled code, but it is not in the OS Null partition area, the exception is mapped to the AccessViolationException class.
If there is no legacyNullReferencePolicy, and the address at which the read/write was attempted is in JIT-compiled code and in the OS Null partition area, the exception is mapped to the NullReferenceException class.
Any SEH exception that is not automatically mapped to a specific exception is mapped to the SEHException class by default.
For more information, search on "unmanaged exceptions" and "Structured Exception Handling" in the MSDN Library.
Note that the SEHException class does not cause unmanaged C++ exception destructors to be called. To ensure that unmanaged C++ exception destructors are called, use the following syntax in the catch block.
[Visual Basic]
Catch
' Handle catch here.
End Try
[C#]
catch
{
// Handle catch here.
}
[C++]
catch(…)
{
// Handle catch here.
}
System.Exception
System.SystemException
System.Runtime.InteropServices.ExternalException
System.Runtime.InteropServices.SEHException
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.