Table 7-2. Mapping between managed exceptions and HRESULTs
.NET exception class name | HRESULT name(hex value of HRESULT) |
---|
AccessException | COR_E_MEMBERACCESS (0x8013151A) |
AmbiguousMatchException | COR_E_AMBIGUOUSMATCH (0X80138000211D) |
appdomainUnloadedException | MSEE_E_APPDOMAINUNLOADED (0x80131015) |
ApplicationException | COR_E_APPLICATION (0x80131600) |
ArgumentException | COR_E_ARGUMENT (0x80070057 ) |
ArgumentNullException | E_POINTER (0x80004003) |
ArgumentOutOfRangeException | COR_E_ARGUMENTOUTOFRANGE (0x80131502) |
ArithmeticException | COR_E_ARITHMETIC (0x80070216) |
ArrayTypeMismatchException | COR_E_ARRAYTYPEMISMATCH (0x80131503) |
BadImageFormatException | COR_E_BADIMAGEFORMAT (0x8007000B) |
CannotUnloadappdomainException | COR_E_CANNOTUNLOADAPPDOMAIN (0x80131015) |
COMException | Any other hrESULT defaults to this .Net Exception |
ContextMarshalException | COR_E_CONTEXTMARSHAL (0x80090020) |
CryptographicException | NTE_FAIL (0x80004001) |
CryptographicUnexpectedOperationException | CORSEC_E_CRYPTO_UNEX_OPER (0x80131431) |
CustomAttributeFormatException | COR_E_FORMAT (0x80131537) |
DirectoryNotFoundException | COR_E_DIRECTORYNOTFOUND (0x80070003) STG_E_PATHNOTFOUND (0x80030003) |
DivideByZeroException | COR_E_DIVIDEBYZERO (0x80020012) |
DllNotFoundException | COR_E_DLLNOTFOUND (0x80131524) |
DuplicateWaitObjectException | COR_E_DUPLICATEWAITOBJECT (0x80131529) |
EndOfStreamException | COR_E_ENDOFSTREAM (0x801338) |
EntryPointNotFoundException | COR_E_TYPELOAD (0x80131522) |
Exception | COR_E_EXCEPTION (0x80131500) |
ExecutionEngineException | COR_E_EXECUTIONENGINE (0x80131506) |
ExternalException | E_FAIL (0x80004005) |
FieldAccessException | COR_E_FIELDACCESS (0x80131507) |
FileLoadException | COR_E_FILELOAD (0x80131621 or 0x80131018) |
FileNotFoundException | COR_E_FILENOTFOUND (0x80070002) |
FormatException | COR_E_FORMAT (0x80131537) |
IndexOutOfRangeException | COR_E_INDEXOUTOFRANGE (0x80131508) |
InvalidCastException | COR_E_INVALIDCAST (0x80004002) |
InvalidComObjectException | COR_E_INVALIDCOMOBJECT (0x80131527) |
InvalidFilterCriteriaException | COR_E_INVALIDFILTERCRITERIA (0x80131601) |
InvalidOleVariantTypeException | COR_E_INVALIDOLEVARIANTTYPE (0x80131531) |
InvalidOperationException | COR_E_INVALIDOPERATION (0x80131509) |
InvalidProgramException | COR_E_INVALIDPROGRAM (0x8013153A) |
IOException | COR_E_IO (0x80131620) |
IsolatedStorageException | ISS_E_ISOSTORE (0x80131450) |
MarshalDirectiveException | COR_E_MARSHALDIRECTIVE (0x80131535) |
MethodAccessException | COR_E_METHODACCESS (0x80131510) |
MissingFieldException | COR_E_MISSINGFIELD (0x80131511) |
MissingManifestResourceException | COR_E_MISSINGMANIFESTRESOURCE (0x80131532) |
MissingMemberException | COR_E_MISSINGMEMBER (0x80131512) |
MissingMethodException | COR_E_MISSINGMETHOD (0x80131513) |
MulticastNotSupportedException | COR_E_MULTICASTNOTSUPPORTED (0x80131514) |
NotFiniteNumberException | COR_E_NOTFINITENUMBER (0x80131528) |
NotImplementedException | E_NOTIMPL (0x80004001) |
NotSupportedException | COR_E_NOTSUPPORTED (0x80131515) |
NullReferenceException | COR_E_NULLREFERENCE (0x80004003) |
OutOfMemoryException | COR_E_OUTOFMEMORY (0x8007000E) |
OverflowException | COR_E_OVERFLOW (0x80131516) |
PathTooLongException | COR_E_PATHTOOLONG (0x8013206) |
PlatformNotSupportedException | COR_E_PLATFORMNOTSUPPORTED (0x80131539) |
PolicyException | CORSEC_E_POLICY_EXCEPTION |
RankException | COR_E_RANK (0x80131517) |
ReflectionTypeLoadException | COR_E_REFLECTIONTYPELOAD (0x80131602) |
RemotingException | COR_E_REMOTING (0x8013150B) |
RemotingTimeoutException | COR_E_REMOTING (0x8013150B) |
SafeArrayTypeMismatchException | COR_E_SAFEARRAYTYPEMISMATCH (0x80131533) |
SafeArrayRankMismatchException | COR_E_SAFEARRAYRANKMISMATCH (0x80131538) |
SecurityException | COR_E_SECURITY (0x8013150A) |
SEHException | E_FAIL (0x80004005) |
SerializationException | COR_E_SERIALIZATION (0x8013150C) |
ServerException | COR_E_SERVER (0x8013150E) |
StackOverflowException | COR_E_STACKOVERFLOW (0x800703E9) |
SUDSGeneratorException | COR_E_EXCEPTION (0x80131500) |
SUDSParserException | COR_E_EXCEPTION (0x80131500) |
SynchronizationLockException | COR_E_SYNCHRONIZATIONLOCK (0x80131518) |
SystemException | COR_E_SYSTEM (0x80131501) |
TargetException | COR_E_TARGET |
TargetInvocationException | COR_E_TARGETINVOCATION (0x80131604) |
TargetParameterCountException | COR_E_TARGETPARAMCOUNT (0x80138002) |
ThreadAbortException | COR_E_THREADABORTED (0x80131530) |
ThreadInterruptedException | COR_E_THREADINTERRUPTED (0x80131519) |
ThreadStateException | COR_E_THREADSTATE (0x80131520) |
ThreadStopException | COR_E_THREADSTOP |
TypeInitializationException | COR_E_TYPEINITIALIZATION (0x80131534) |
TypeLoadException | COR_E_TYPELOAD (0x80131522) |
TypeUnloadedException | COR_E_TYPEUNLOADED (0x80131013) |
UnauthorizedAccessException | COR_E_UNAUTHORIZEDACCESS (0x80070005) |
VerificationException | COR_E_VERIFICATION |
WeakReferenceException | COR_E_WEAKREFERENCE |
Handling exceptions generated by COM/COM+ components involves the following two steps:
See Recipe 7.9; see the "Error Raising and Handling Guidelines," "HRESULTs and Exceptions," and "Handling COM Interop Exceptions" topics in the MSDN documentation.