简介
此表旨在帮助将Windows运行时应用程序错误代码交叉引用到Microsoft.NET标准异常,这些异常可以作为应用程序异常处理技术的一部分。
对照表
.NET Exception (Namespace)
HRESULT(s) - symbolic
HRESULT(s) - raw
AccessViolationException
E_POINTER
0x80004003
AmbiguousMatchException (System.Reflection)
COR_E_AMBIGUOUSMATCH
0x8000211d
ApplicationException
COR_E_APPLICATION
0x80131600
AppDomainUnloadedException
COR_E_APPDOMAINUNLOADED
0x80131014
ArithmeticException
COR_E_ARITHMETIC
0x80070216
ArgumentException
COR_E_ARGUMENT
0x80070057
ArgumentNullException
E_POINTER
0x80004003
ArgumentOutOfRangeException
COR_E_ARGUMENTOUTOFRANGE
0x80131502
ERROR_NO_UNICODE_TRANSLATION
0x80070459
ArrayTypeMismatchException
COR_E_ARRAYTYPEMISMATCH
0x80131503
BadImageFormatException
COR_E_BADIMAGEFORMAT
0x8007000b
CLDB_E_FILE_OLDVER
0x80131107
CLDB_E_INDEX_NOTFOUND
0x80131124
CLDB_E_FILE_CORRUPT
0x8013110e
COR_E_NEWER_RUNTIME
0x8013101b
COR_E_ASSEMBLYEXPECTED
0x80131018
ERROR_BAD_EXE_FORMAT
0x800700c1
ERROR_EXE_MARKED_INVALID
0x800700c0
CORSEC_E_INVALID_IMAGE_FORMAT
0x8013141d
ERROR_NOACCESS
0x800703e6
ERROR_INVALID_ORDINAL
0x800700b6
ERROR_INVALID_DLL
0x80070482
ERROR_FILE_CORRUPT
0x80070570
COR_E_LOADING_REFERENCE_ASSEMBLY
0x80131058
META_E_BAD_SIGNATURE
0x80131192
CannotUnloadAppDomainException
COR_E_CANNOTUNLOADAPPDOMAIN
0x80131015
ContractException (System.Diagnostics.Contracts)
COR_E_CODECONTRACTFAILED
0x80131542
ContextMarshalException (System)
COR_E_CONTEXTMARSHAL
0x80131504
CustomAttributeFormatException (System.Reflection)
COR_E_CUSTOMATTRIBUTEFORMAT
0x80131605
CryptographicException (System.Security.Cryptography)
CORSEC_E_CRYPTO
0x80131430
CryptographicUnexpectedOperationException (System.Security.Cryptography)
CORSEC_E_CRYPTO_UNEX_OPER
0x80131431
DataMisalignedException
COR_E_DATAMISALIGNED
0x80131541
DirectoryNotFoundException (System.IO)
COR_E_DIRECTORYNOTFOUND
0x80070003
STG_E_PATHNOTFOUND
0x80030003
CTL_E_PATHNOTFOUND
0x800a004c
DivideByZeroException
COR_E_DIVIDEBYZERO
0x80020012
CTL_E_DIVISIONBYZERO
0x800a000b
DllNotFoundException
COR_E_DLLNOTFOUND
0x80131524
DuplicateWaitObjectException
COR_E_DUPLICATEWAITOBJECT
0x80131529
EndOfStreamException (System.IO)
COR_E_ENDOFSTREAM
0x80070026
EntryPointNotFoundException
COR_E_ENTRYPOINTNOTFOUND
0x80131523
Exception
COR_E_EXCEPTION
0x80131500
ExecutionEngineException
COR_E_EXECUTIONENGINE
0x80131506
FieldAccessException
COR_E_FIELDACCESS
0x80131507
FileLoadException (System.IO)
COR_E_FILELOAD
0x80131621
FUSION_E_INVALID_PRIVATE_ASM_LOCATION
0x80131041
FUSION_E_SIGNATURE_CHECK_FAILED
0x80131045
FUSION_E_LOADFROM_BLOCKED
0x80131051
FUSION_E_CACHEFILE_FAILED
0x80131052
FUSION_E_ASM_MODULE_MISSING
0x80131042
FUSION_E_INVALID_NAME
0x80131047
FUSION_E_PRIVATE_ASM_DISALLOWED
0x80131044
FUSION_E_HOST_GAC_ASM_MISMATCH
0x80131050
COR_E_MODULE_HASH_CHECK_FAILED
0x80131039
FUSION_E_REF_DEF_MISMATCH
0x80131040
SECURITY_E_INCOMPATIBLE_SHARE
0x80131401
SECURITY_E_INCOMPATIBLE_EVIDENCE
0x80131403
SECURITY_E_UNVERIFIABLE
0x80131402
COR_E_FIXUPSINEXE
0x80131019
ERROR_TOO_MANY_OPEN_FILES
0x80070004
ERROR_SHARING_VIOLATION
0x80070020
ERROR_LOCK_VIOLATION
0x80070021
ERROR_OPEN_FAILED
0x8007006e
ERROR_DISK_CORRUPT
0x80070571
ERROR_UNRECOGNIZED_VOLUME
0x800703ed
ERROR_DLL_INIT_FAILED
0x8007045a
FUSION_E_CODE_DOWNLOAD_DISABLED
0x80131048
CORSEC_E_MISSING_STRONGNAME
0x8013141b
MSEE_E_ASSEMBLYLOADINPROGRESS
0x80131016
ERROR_FILE_INVALID
0x800703ee
FileNotFoundException (System.IO)
ERROR_FILE_NOT_FOUND
0x80070002
ERROR_MOD_NOT_FOUND
0x8007007e
ERROR_INVALID_NAME
0x8007007b
CTL_E_FILENOTFOUND
0x800a0035
ERROR_PATH_NOT_FOUND
0x80070003
ERROR_BAD_NET_NAME
0x80070043
ERROR_BAD_NETPATH
0x80070035
ERROR_NOT_READY
0x80070015
ERROR_WRONG_TARGET_NAME
0x80070574
INET_E_UNKNOWN_PROTOCOL
0x800c000d
INET_E_CONNECTION_TIMEOUT
0x800c000b
INET_E_CANNOT_CONNECT
0x800c0004
INET_E_RESOURCE_NOT_FOUND
0x800c0005
INET_E_OBJECT_NOT_FOUND
0x800c0006
INET_E_DOWNLOAD_FAILURE
0x800c0008
INET_E_DATA_NOT_AVAILABLE
0x800c0007
ERROR_DLL_NOT_FOUND
0x80070485
CLR_E_BIND_ASSEMBLY_VERSION_TOO_LOW
0x80132000
CLR_E_BIND_ASSEMBLY_PUBLIC_KEY_MISMATCH
0x80132001
CLR_E_BIND_ASSEMBLY_NOT_FOUND
0x80132004
FormatException
COR_E_FORMAT
0x80131537
IndexOutOfRangeException
COR_E_INDEXOUTOFRANGE
0x80131508
InsufficientExecutionStackException
COR_E_INSUFFICIENTEXECUTIONSTACK
0x80131578
InvalidCastException
COR_E_INVALIDCAST
0x80004002
InvalidComObjectException (System.Runtime.InteropServices)
COR_E_INVALIDCOMOBJECT
0x80131527
InvalidFilterCriteriaException (System.Reflection)
COR_E_INVALIDFILTERCRITERIA
0x80131601
InvalidOleVariantTypeException (System.Runtime.InteropServices)
COR_E_INVALIDOLEVARIANTTYPE
0x80131531
InvalidOperationException
COR_E_INVALIDOPERATION
0x80131509
InvalidProgramException
COR_E_INVALIDPROGRAM
0x8013153a
IOException (System.IO)
COR_E_IO
0x80131620
CTL_E_DEVICEIOERROR
0x800a0039
IsolatedStorageException (System.IO.IsolatedStorage)
ISS_E_ISOSTORE
0x80131450
ISS_E_OPEN_STORE_FILE
0x80131460
ISS_E_OPEN_FILE_MAPPING
0x80131461
ISS_E_MAP_VIEW_OF_FILE
0x80131462
ISS_E_GET_FILE_SIZE
0x80131463
ISS_E_CREATE_MUTEX
0x80131464
ISS_E_LOCK_FAILED
0x80131465
ISS_E_FILE_WRITE
0x80131466
ISS_E_SET_FILE_POINTER
0x80131467
ISS_E_CREATE_DIR
0x80131468
ISS_E_CORRUPTED_STORE_FILE
0x80131480
ISS_E_STORE_VERSION
0x80131481
ISS_E_FILE_NOT_MAPPED
0x80131482
ISS_E_BLOCK_SIZE_TOO_SMALL
0x80131483
ISS_E_ALLOC_TOO_LARGE
0x80131484
ISS_E_USAGE_WILL_EXCEED_QUOTA
0x80131485
ISS_E_TABLE_ROW_NOT_FOUND
0x80131486
ISS_E_DEPRECATE
0x801314a0
ISS_E_CALLER
0x801314a1
ISS_E_PATH_LENGTH
0x801314a2
ISS_E_MACHINE
0x801314a3
ISS_E_STORE_NOT_OPEN
0x80131469
ISS_E_MACHINE_DACL
0x801314a4
MarshalDirectiveException (System.Runtime.InteropServices)
COR_E_MARSHALDIRECTIVE
0x80131535
MethodAccessException
COR_E_METHODACCESS
0x80131510
META_E_CA_FRIENDS_SN_REQUIRED
0x801311e6
MemberAccessException
COR_E_MEMBERACCESS
0x8013151a
MissingFieldException
COR_E_MISSINGFIELD
0x80131511
MissingManifestResourceException (System.Resources)
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
ObjectDisposedException
COR_E_OBJECTDISPOSED
0x80131622
RO_E_CLOSED
0x80000013
OperationCanceledException
COR_E_OPERATIONCANCELED
0x8013153b
OutOfMemoryException
E_OUTOFMEMORY
0x8007000e
CTL_E_OUTOFMEMORY
0x800a0007
OverflowException
COR_E_OVERFLOW
0x80131516
CTL_E_OVERFLOW
0x800a0006
PathTooLongException (System.IO)
COR_E_PATHTOOLONG
0x800700ce
PlatformNotSupportedException
COR_E_PLATFORMNOTSUPPORTED
0x80131539
System.RankException
COR_E_RANK
0x80131517
ReflectionTypeLoadException (System.Reflection)
COR_E_REFLECTIONTYPELOAD
0x80131602
RemotingException (System.Runtime.Remoting)
COR_E_REMOTING
0x8013150b
RuntimeWrappedException (System.Runtime.CompilerServices)
COR_E_RUNTIMEWRAPPED
0x8013153e
ServerException (System.Runtime.Remoting)
COR_E_SERVER
0x8013150e
SecurityException (System.Security)
COR_E_SECURITY
0x8013150a
CORSEC_E_INVALID_STRONGNAME
0x8013141a
CTL_E_PERMISSIONDENIED
0x800a0046
CORSEC_E_INVALID_PUBLICKEY
0x8013141e
CORSEC_E_SIGNATURE_MISMATCH
0x80131420
SafeArrayRankMismatchException System.Runtime.InteropServices)
COR_E_SAFEARRAYRANKMISMATCH
0x80131538
SafeArrayTypeMismatchException (System.Runtime.InteropServices)
COR_E_SAFEARRAYTYPEMISMATCH
0x80131533
SerializationException (System.Runtime.Serialization)
COR_E_SERIALIZATION
0x8013150c
StackOverflowException
COR_E_STACKOVERFLOW
0x800703e9
CTL_E_OUTOFSTACKSPACE
0x800a001c
SynchronizationLockException (System.Threading)
COR_E_SYNCHRONIZATIONLOCK
0x80131518
SystemException
COR_E_SYSTEM
0x80131501
TargetException (System.Reflection)
COR_E_TARGET
0x80131603
TargetInvocationException (System.Reflection)
COR_E_TARGETINVOCATION
0x80131604
TargetParameterCountException (System.Reflection)
COR_E_TARGETPARAMCOUNT
0x8002000e
ThreadAbortException (System.Threading)
COR_E_THREADABORTED
0x80131530
ThreadInterruptedException (System.Threading)
COR_E_THREADINTERRUPTED
0x80131519
ThreadStateException (System.Threading)
COR_E_THREADSTATE
0x80131520
ThreadStartException (System.Threading)
COR_E_THREADSTART
0x80131525
TypeAccessException
COR_E_TYPEACCESS
0x80131543
TypeInitializationException
COR_E_TYPEINITIALIZATION
0x80131534
TypeLoadException
COR_E_TYPELOAD
0x80131522
RO_E_METADATA_NAME_NOT_FOUND
0x8000000f
CLR_E_BIND_TYPE_NOT_FOUND
0x80132005
TypeUnloadedException
COR_E_TYPEUNLOADED
0x80131013
UnauthorizedAccessException
COR_E_UNAUTHORIZEDACCESS
0x80070005
CTL_E_PATHFILEACCESSERROR
0x800a004b
VerificationException (System.Security)
COR_E_VERIFICATION
0x8013150d
PolicyException (System.Security.Policy)
CORSEC_E_POLICY_EXCEPTION
0x80131416
CORSEC_E_NO_EXEC_PERM
0x80131418
CORSEC_E_MIN_GRANT_FAIL
0x80131417
XmlSyntaxException (System.Security)
CORSEC_E_XMLSYNTAX
0x80131419
COMException (System.Runtime.InteropServices)
E_FAIL
0x80004005
ExternalException (System.Runtime.InteropServices)
E_FAIL
0x80004005
SEHException (System.Runtime.InteropServices)
E_FAIL
0x80004005
ElementNotAvailableException (Windows.UI.Xaml.Automation)
(none)
0x802b001f
ElementNotEnabledException (Windows.UI.Xaml.Automation)
(none)
0x802b001e
LayoutCycleException (Windows.UI.Xaml)
(none)
0x802b0014
XamlParseException (Windows.UI.Xaml.Markup)
(none)
0x802b000a
说明
在上表的“.NET异常”列中,如果链接了异常名称,则该异常是.NET for Windows运行时应用程序类的一部分。这意味着您可以在自己的代码中引发该类型的新异常。或者您可以捕获这些异常,特别是作为try-catch或UnhandledException异常处理的一部分。如果未链接异常名称,则该异常不属于.NET for Windows运行时类的一部分。不属于.NET for Windows运行时集的异常可能在某些互操作方案中遇到,也可能来自系统或Windows运行时内部。您将无法使用该特定异常类型为它们编写捕获块,因为您为Windows运行时应用程序运行的.NET库不知道该类型。但是您仍然可以读取一个HRESULT代码,从“HRESULT(s)-raw:”列中查找它,并注意到有一个对应的.NET异常。或者你可以把它当作一般的例外。然后,您可以阅读.NET文档,或许可以了解有关该异常的意图以及原始代码引发该异常的原因的更多信息,即使该异常未在.NET for Windows运行时类型中表示。如果没有为.NET异常列出命名空间,则它来自系统命名空间。
“HRESULT(s)-symbolic”列中列出的常量来自多种来源。有些是在winerror.h中定义的,有些是在特定于组件对象模型(COM)编程的头文件中定义的,有些是在属于Windows特定子系统的头文件中定义的。有些需要HRESULT_From_Win32宏用法,其中包含来自更早的常量集的代码(前面是ERROR_)。对于使用.NET语言时的典型Windows运行时编程,这些头文件不是作为项目的一部分提供的。如果您正在获取系统无法映射到标准异常的情况下的错误代码信息,则可能会将其视为原始整数或十六进制值,并且不会自动支持将数字代码别名为Windows命名的常量值。尽管如此,在以前的Windows错误报告系统的基础上,仍然存在按其命名常量而不是原始代码引用错误代码的历史。您可以使用表中的命名常量进一步研究其他文档源(如论坛或支持文档)中的错误,特别是该错误对桌面编程、Microsoft Win32和COM等意味着什么。
SystemException:在原始的.NET异常层次结构中,许多异常是从系统异常派生的。例如,从SystemException派生的System.ArgumentException。从SystemException继承表明.NET核心定义了异常。Windows运行时的.NET类集合中未包含系统异常。所有在完整框架下从SystemException派生的异常都是从System.Exception派生的。
COMException:NET文档建议对任何无法识别的HRESULT抛出COMException,但这不是Windows运行时应用的行为。相反,COMException通常是用于源于组件的未映射异常的标准异常。来自您自己的应用程序代码或系统的未映射异常报告为基本异常,其HResult值不标准。
ExternalException:不包含在.NET for Windows运行时中。对于确实存在的异常(如SEHException),在层次结构中看不到这一点。