Partager via


Cross-reference: Standard exceptions and error codes

[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]

his table is intended as an aid for cross-referencing Windows Runtime app error codes to the Microsoft .NET standard exceptions that you can catch as part of your app's exception handling techniques. For more info on those techniques, see Exception handling for Windows Runtime apps in C# or Visual Basic.

.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

 

Notes

In the ".NET Exception" column of the table above, if the exception name is linked, that exception is part of the classes for .NET for Windows Runtime apps. That means you could raise a new exception of that type in your own code. Or you can catch those exceptions specifically as part of your exception handling for try-catch or UnhandledException. If the exception name is not linked, that exception is not part of the classes for .NET for Windows Runtime. The exceptions that aren't part of the .NET for Windows Runtime set might be encountered in certain interop scenarios, or might come from system or Windows Runtime internals. You won't be able to write catch blocks for them using that specific exception type, because that type isn't known to the .NET libraries you're running for Windows Runtime apps. But you still might be able to read an HRESULT code, look it up from the "HRESULT(s) - raw:" column, and note that there is a .NET exception that corresponds. Or you can catch it as a general Exception. Then you can read the .NET documentation and perhaps learn more about the intention of that exception and the reasons that the originating code might have thrown that exception, even if that exception wasn't represented in the .NET for Windows Runtime types.

If no (Namespace) is listed for a .NET exception, it's from the System namespace.

The constants listed in the "HRESULT(s) - symbolic" column come from a variety of sources. Some are defined in winerror.h. Some are defined in headers that are specific to Component Object Model (COM) programming, or in headers that are part of specific subsystems of Windows. Some require HRESULT_From_Win32 macro usages with codes from even earlier sets of constants (these are the ones preceded with ERROR_). For typical Windows Runtime programming when you're using a .NET language, these headers are not something that you'd have included as part of your project. If you are getting error code info for the cases where the system can't map to a standard exception, you'll probably see it as a raw integer or hex value and won't have automatic support that aliases the numeric code to the Windows named constant values. Still, there's a history of referencing error codes by their named constants instead of raw codes, based on previous Windows error reporting systems. You may be able to use the named constants you see in the table as a way to further research the error in other documentation sources such as forums or support documents, in particular what that error meant for desktop programming, Microsoft Win32 and COM, and so on.

SystemException: In the original .NET exception hierarchy, many exceptions derived from SystemException. For example, System.ArgumentException derived from SystemException. Inheritance from SystemException indicated that an exception was defined by the .NET core. SystemException wasn't included in the set of classes for .NET for Windows Runtime. All the exceptions that would have derived from SystemException under the full framework instead derive from System.Exception.

COMException: The .NET documentation suggests that COMException would be thrown for any unrecognized HRESULT, but that's not the behavior for Windows Runtime apps. Instead, COMException is typically the standard exception used for unmapped exceptions that originate from components. Unmapped exceptions from your own app code or from the system are reported as the base Exception, with a nonstandard HResult value.

ExternalException: Not included in .NET for Windows Runtime. You won't see this in the hierarchy for exceptions that do exist (like SEHException).

Exception handling for Windows Store apps in C# or Visual Basic

System.Exception

Exceptions (C++/CX)

Debug Windows Runtime apps in Visual Studio