1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//====================================================================
//
// Purpose: Lists the commonly-used Runtime Exceptions visible to users.
//
//
//====================================================================
// If you add an exception, modify CorError.h to add an HResult there.
// (Guidelines for picking a unique number for your HRESULT are in CorError.h)
// Also modify your managed Exception class to include its HResult.
// Modify __HResults in the same directory as your exception, to include
// your new HResult. And of course, add your exception and symbolic
// name for your HResult to the list below so it can be thrown from
// within the EE and recognized in Interop scenarios.
//
// Note: This file gets parsed by the Mono IL Linker (https://github.com/mono/linker/) which may throw an exception during parsing.
// Specifically, this (https://github.com/mono/linker/blob/master/corebuild/integration/ILLink.Tasks/CreateRuntimeRootDescriptorFile.cs) will try to
// parse this header, and it may throw an exception while doing that. If you edit this file and get a build failure on msbuild.exe D:\repos\coreclr\build.proj
// you might want to check out the parser linked above.
//
// This is an exhaustive list of all exceptions that can be
// thrown by the EE itself. If you add to this list the IL spec
// needs to be updated!
// Note: When multiple exceptions map to the same hresult it is very important
// that the exception that should be created when the hresult in question
// is returned by a function be FIRST in the list.
//
//
// These are the macro's that need to be implemented before this file is included.
//
//
// EXCEPTION_BEGIN_DEFINE(ns, reKind, bHRformessage, ...)
//
// This macro starts an exception definition.
//
// ns Namespace of the exception.
// reKind Name of the exception.
// bHRformessage When the exception is thrown from the EE, if this argument is true
// the EE will create a string with the HRESULT, so that you get a more
// meaningful error message than let's say AssemblyLoadException.
// Usually you want to set this to true if your exception corresponds to
// more than one HRESULT.
// ... The list of HRESULTs that map to this exception. The first of the list
// is used as the representative HRESULT for the reKind value.
//
//
// #define EXCEPTION_ADD_HR(hr)
//
// This macro adds an additional HRESULT that maps to the exception.
//
// hr Additional HRESULT that maps to the exception.
//
//
// #define EXCEPTION_END_DEFINE()
//
// This macro terminates the exception definition.
//
//
// Namespaces used to define the exceptions.
//
#include "namespace.h"
// Temporary workaround - adding some HRESULTs that the Jupiter team will define and
// add to one of their header files for errors. Once these have been RI'ed into
// windows and are in a file adjacent to winerror.h, we can remove these constants.
// Given integration time, remove this by August 2011 at the very latest.
#ifndef E_XAMLPARSEFAILED
#define E_XAMLPARSEFAILED _HRESULT_TYPEDEF_(0x802B000AL)
#endif
#ifndef E_LAYOUTCYCLE
#define E_LAYOUTCYCLE _HRESULT_TYPEDEF_(0x802B0014L)
#endif
#ifndef E_ELEMENTNOTENABLED
#define E_ELEMENTNOTENABLED _HRESULT_TYPEDEF_(0x802B001EL)
#endif
#ifndef E_ELEMENTNOTAVAILABLE
#define E_ELEMENTNOTAVAILABLE _HRESULT_TYPEDEF_(0x802B001FL)
#endif
#ifndef RO_E_CLOSED
#define RO_E_CLOSED _HRESULT_TYPEDEF_(0x80000013L)
#endif
#ifndef APPMODEL_ERROR_NO_PACKAGE
#define APPMODEL_ERROR_NO_PACKAGE 15700L
#endif
//
// Actual definition of the exceptions and their matching HRESULT's.
// HRESULTs are expected to be defined in CorError.h, and must also be
// redefined in managed code in an __HResults class. The managed exception
// object MUST use the same HRESULT in all of its constructors for COM Interop.
// Read comments near top of this file.
//
//
// NOTE: Please keep this list sorted according to the name of the exception.
//
//
DEFINE_EXCEPTION(g_ReflectionNS, AmbiguousMatchException, false, COR_E_AMBIGUOUSMATCH)
DEFINE_EXCEPTION(g_SystemNS, ApplicationException, false, COR_E_APPLICATION)
DEFINE_EXCEPTION(g_SystemNS, ArithmeticException, false, COR_E_ARITHMETIC)
DEFINE_EXCEPTION(g_SystemNS, ArgumentException, false,
COR_E_ARGUMENT, STD_CTL_SCODE(449), STD_CTL_SCODE(450), CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT)
DEFINE_EXCEPTION(g_SystemNS, ArgumentOutOfRangeException, false, COR_E_ARGUMENTOUTOFRANGE, HRESULT_FROM_WIN32(ERROR_NO_UNICODE_TRANSLATION))
DEFINE_EXCEPTION(g_SystemNS, ArrayTypeMismatchException, false, COR_E_ARRAYTYPEMISMATCH)
// Keep in sync with the list in EEFileLoadException::GetFileLoadKind in clrex.cpp
DEFINE_EXCEPTION(g_SystemNS, BadImageFormatException, true,
COR_E_BADIMAGEFORMAT, CLDB_E_FILE_OLDVER,
CLDB_E_INDEX_NOTFOUND,
CLDB_E_FILE_CORRUPT, COR_E_NEWER_RUNTIME,
COR_E_ASSEMBLYEXPECTED,
HRESULT_FROM_WIN32(ERROR_BAD_EXE_FORMAT),
HRESULT_FROM_WIN32(ERROR_EXE_MARKED_INVALID),
CORSEC_E_INVALID_IMAGE_FORMAT,
HRESULT_FROM_WIN32(ERROR_NOACCESS),
HRESULT_FROM_WIN32(ERROR_INVALID_ORDINAL),
HRESULT_FROM_WIN32(ERROR_INVALID_DLL),
HRESULT_FROM_WIN32(ERROR_FILE_CORRUPT),
IDS_CLASSLOAD_32BITCLRLOADING64BITASSEMBLY,
COR_E_LOADING_REFERENCE_ASSEMBLY,
META_E_BAD_SIGNATURE,
COR_E_LOADING_WINMD_REFERENCE_ASSEMBLY)
// CannotUnloadAppDomainException is removed in CoreCLR
#define kCannotUnloadAppDomainException kException
DEFINE_EXCEPTION(g_CodeContractsNS, ContractException, false, COR_E_CODECONTRACTFAILED)
DEFINE_EXCEPTION(g_ReflectionNS, CustomAttributeFormatException, false, COR_E_CUSTOMATTRIBUTEFORMAT)
DEFINE_EXCEPTION(g_CryptographyNS, CryptographicException, false, CORSEC_E_CRYPTO)
DEFINE_EXCEPTION(g_SystemNS, DataMisalignedException, false, COR_E_DATAMISALIGNED)
DEFINE_EXCEPTION(g_IONS, DirectoryNotFoundException, true, COR_E_DIRECTORYNOTFOUND, STG_E_PATHNOTFOUND, CTL_E_PATHNOTFOUND)
DEFINE_EXCEPTION(g_SystemNS, DivideByZeroException, false, COR_E_DIVIDEBYZERO, CTL_E_DIVISIONBYZERO)
DEFINE_EXCEPTION(g_SystemNS, DllNotFoundException, false, COR_E_DLLNOTFOUND)
DEFINE_EXCEPTION(g_SystemNS, DuplicateWaitObjectException, false, COR_E_DUPLICATEWAITOBJECT)
DEFINE_EXCEPTION(g_IONS, EndOfStreamException, false, COR_E_ENDOFSTREAM, STD_CTL_SCODE(62))
DEFINE_EXCEPTION(g_SystemNS, EntryPointNotFoundException, false, COR_E_ENTRYPOINTNOTFOUND)
DEFINE_EXCEPTION(g_SystemNS, Exception, false, COR_E_EXCEPTION)
DEFINE_EXCEPTION(g_SystemNS, ExecutionEngineException, false, COR_E_EXECUTIONENGINE)
DEFINE_EXCEPTION(g_SystemNS, FieldAccessException, false, COR_E_FIELDACCESS)
DEFINE_EXCEPTION(g_IONS, FileLoadException, true,
COR_E_FILELOAD, FUSION_E_INVALID_PRIVATE_ASM_LOCATION,
FUSION_E_SIGNATURE_CHECK_FAILED,
FUSION_E_LOADFROM_BLOCKED, FUSION_E_CACHEFILE_FAILED,
FUSION_E_ASM_MODULE_MISSING, FUSION_E_INVALID_NAME,
FUSION_E_PRIVATE_ASM_DISALLOWED, FUSION_E_HOST_GAC_ASM_MISMATCH,
COR_E_MODULE_HASH_CHECK_FAILED, FUSION_E_REF_DEF_MISMATCH,
SECURITY_E_INCOMPATIBLE_SHARE, SECURITY_E_INCOMPATIBLE_EVIDENCE,
SECURITY_E_UNVERIFIABLE, COR_E_FIXUPSINEXE, HRESULT_FROM_WIN32(ERROR_TOO_MANY_OPEN_FILES),
HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION), HRESULT_FROM_WIN32(ERROR_LOCK_VIOLATION),
HRESULT_FROM_WIN32(ERROR_OPEN_FAILED), HRESULT_FROM_WIN32(ERROR_DISK_CORRUPT),
HRESULT_FROM_WIN32(ERROR_UNRECOGNIZED_VOLUME),
HRESULT_FROM_WIN32(ERROR_DLL_INIT_FAILED),
FUSION_E_CODE_DOWNLOAD_DISABLED, CORSEC_E_MISSING_STRONGNAME,
MSEE_E_ASSEMBLYLOADINPROGRESS,
HRESULT_FROM_WIN32(ERROR_FILE_INVALID))
DEFINE_EXCEPTION(g_IONS, FileNotFoundException, true,
HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND),
HRESULT_FROM_WIN32(ERROR_INVALID_NAME), CTL_E_FILENOTFOUND,
HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), HRESULT_FROM_WIN32(ERROR_BAD_NET_NAME),
HRESULT_FROM_WIN32(ERROR_BAD_NETPATH), HRESULT_FROM_WIN32(ERROR_NOT_READY),
HRESULT_FROM_WIN32(ERROR_WRONG_TARGET_NAME), INET_E_UNKNOWN_PROTOCOL,
INET_E_CONNECTION_TIMEOUT, INET_E_CANNOT_CONNECT, INET_E_RESOURCE_NOT_FOUND,
INET_E_OBJECT_NOT_FOUND, INET_E_DOWNLOAD_FAILURE, INET_E_DATA_NOT_AVAILABLE,
HRESULT_FROM_WIN32(ERROR_DLL_NOT_FOUND),
CLR_E_BIND_ASSEMBLY_VERSION_TOO_LOW, CLR_E_BIND_ASSEMBLY_PUBLIC_KEY_MISMATCH,
CLR_E_BIND_ASSEMBLY_NOT_FOUND)
DEFINE_EXCEPTION(g_SystemNS, FormatException, false, COR_E_FORMAT)
DEFINE_EXCEPTION(g_SystemNS, IndexOutOfRangeException, false, COR_E_INDEXOUTOFRANGE, (int)0x800a0009 /*Subscript out of range*/)
DEFINE_EXCEPTION(g_SystemNS, InsufficientExecutionStackException, false, COR_E_INSUFFICIENTEXECUTIONSTACK)
DEFINE_EXCEPTION(g_SystemNS, InvalidCastException, false, COR_E_INVALIDCAST)
#ifdef FEATURE_COMINTEROP
DEFINE_EXCEPTION(g_InteropNS, InvalidComObjectException, false, COR_E_INVALIDCOMOBJECT)
#endif //FEATURE_COMINTEROP
DEFINE_EXCEPTION(g_ReflectionNS, InvalidFilterCriteriaException, false, COR_E_INVALIDFILTERCRITERIA)
DEFINE_EXCEPTION(g_InteropNS, InvalidOleVariantTypeException, false, COR_E_INVALIDOLEVARIANTTYPE)
DEFINE_EXCEPTION(g_SystemNS, InvalidOperationException, false, COR_E_INVALIDOPERATION)
#ifdef FEATURE_COMINTEROP
DEFINE_EXCEPTION_HR_WINRT_ONLY(g_SystemNS, InvalidOperationException, COR_E_INVALIDOPERATION,
E_ILLEGAL_STATE_CHANGE,
E_ILLEGAL_METHOD_CALL,
E_ILLEGAL_DELEGATE_ASSIGNMENT,
HRESULT_FROM_WIN32(APPMODEL_ERROR_NO_PACKAGE))
#endif // FEATURE_COMINTEROP
DEFINE_EXCEPTION(g_SystemNS, InvalidProgramException, false, COR_E_INVALIDPROGRAM)
DEFINE_EXCEPTION(g_IONS, IOException, false, COR_E_IO, CTL_E_DEVICEIOERROR, STD_CTL_SCODE(31036), STD_CTL_SCODE(31037))
DEFINE_EXCEPTION(g_InteropNS, MarshalDirectiveException, false, COR_E_MARSHALDIRECTIVE)
DEFINE_EXCEPTION(g_SystemNS, MethodAccessException, false, COR_E_METHODACCESS, META_E_CA_FRIENDS_SN_REQUIRED)
DEFINE_EXCEPTION(g_SystemNS, MemberAccessException, false, COR_E_MEMBERACCESS)
DEFINE_EXCEPTION(g_SystemNS, MissingFieldException, false, COR_E_MISSINGFIELD)
DEFINE_EXCEPTION(g_ResourcesNS, MissingManifestResourceException, false,COR_E_MISSINGMANIFESTRESOURCE)
DEFINE_EXCEPTION(g_SystemNS, MissingMemberException, false, COR_E_MISSINGMEMBER, STD_CTL_SCODE(461))
DEFINE_EXCEPTION(g_SystemNS, MissingMethodException, false, COR_E_MISSINGMETHOD)
DEFINE_EXCEPTION(g_SystemNS, MulticastNotSupportedException, false, COR_E_MULTICASTNOTSUPPORTED)
DEFINE_EXCEPTION(g_RuntimeNS, AmbiguousImplementationException, false,COR_E_AMBIGUOUSIMPLEMENTATION)
DEFINE_EXCEPTION(g_SystemNS, NotFiniteNumberException, false, COR_E_NOTFINITENUMBER)
DEFINE_EXCEPTION(g_SystemNS, NotSupportedException, false, COR_E_NOTSUPPORTED, STD_CTL_SCODE(438), STD_CTL_SCODE(445), STD_CTL_SCODE(458), STD_CTL_SCODE(459))
DEFINE_EXCEPTION(g_SystemNS, NullReferenceException, false, COR_E_NULLREFERENCE)
// Note: this has to come after NullReferenceException since we want NullReferenceException to be created
// when E_POINTER is returned from COM interfaces.
DEFINE_EXCEPTION(g_SystemNS, AccessViolationException, false, E_POINTER)
DEFINE_EXCEPTION(g_SystemNS, ObjectDisposedException, false, COR_E_OBJECTDISPOSED, RO_E_CLOSED)
DEFINE_EXCEPTION(g_SystemNS, OperationCanceledException, false, COR_E_OPERATIONCANCELED)
DEFINE_EXCEPTION(g_SystemNS, OverflowException, false, COR_E_OVERFLOW, CTL_E_OVERFLOW)
DEFINE_EXCEPTION(g_IONS, PathTooLongException, false, COR_E_PATHTOOLONG)
DEFINE_EXCEPTION(g_SystemNS, PlatformNotSupportedException, false, COR_E_PLATFORMNOTSUPPORTED)
DEFINE_EXCEPTION(g_SystemNS, RankException, false, COR_E_RANK)
DEFINE_EXCEPTION(g_ReflectionNS, ReflectionTypeLoadException, false, COR_E_REFLECTIONTYPELOAD)
DEFINE_EXCEPTION(g_CompilerServicesNS, RuntimeWrappedException, false, COR_E_RUNTIMEWRAPPED)
DEFINE_EXCEPTION(g_SecurityNS, SecurityException, true,
COR_E_SECURITY, CORSEC_E_INVALID_STRONGNAME,
CTL_E_PERMISSIONDENIED, STD_CTL_SCODE(419),
CORSEC_E_INVALID_PUBLICKEY, CORSEC_E_SIGNATURE_MISMATCH)
#if FEATURE_COMINTEROP
DEFINE_EXCEPTION(g_InteropNS, SafeArrayRankMismatchException, false, COR_E_SAFEARRAYRANKMISMATCH)
DEFINE_EXCEPTION(g_InteropNS, SafeArrayTypeMismatchException, false, COR_E_SAFEARRAYTYPEMISMATCH)
#endif //FEATURE_COMINTEROP
DEFINE_EXCEPTION(g_SerializationNS, SerializationException, false, COR_E_SERIALIZATION)
DEFINE_EXCEPTION(g_SystemNS, StackOverflowException, false, COR_E_STACKOVERFLOW, CTL_E_OUTOFSTACKSPACE)
DEFINE_EXCEPTION(g_ThreadingNS, SynchronizationLockException, false, COR_E_SYNCHRONIZATIONLOCK)
DEFINE_EXCEPTION(g_SystemNS, SystemException, false, COR_E_SYSTEM)
DEFINE_EXCEPTION(g_ReflectionNS, TargetException, false, COR_E_TARGET)
DEFINE_EXCEPTION(g_ReflectionNS, TargetInvocationException, false, COR_E_TARGETINVOCATION)
DEFINE_EXCEPTION(g_ReflectionNS, TargetParameterCountException, false, COR_E_TARGETPARAMCOUNT)
DEFINE_EXCEPTION(g_ThreadingNS, ThreadAbortException, false, COR_E_THREADABORTED)
DEFINE_EXCEPTION(g_ThreadingNS, ThreadInterruptedException, false, COR_E_THREADINTERRUPTED)
DEFINE_EXCEPTION(g_ThreadingNS, ThreadStateException, false, COR_E_THREADSTATE)
DEFINE_EXCEPTION(g_ThreadingNS, ThreadStartException, false, COR_E_THREADSTART)
DEFINE_EXCEPTION(g_SystemNS, TypeAccessException, false, COR_E_TYPEACCESS)
DEFINE_EXCEPTION(g_SystemNS, TypeInitializationException, false, COR_E_TYPEINITIALIZATION)
#ifdef FEATURE_COMINTEROP
DEFINE_EXCEPTION(g_SystemNS, TypeLoadException, false, COR_E_TYPELOAD,
RO_E_METADATA_NAME_NOT_FOUND, CLR_E_BIND_TYPE_NOT_FOUND)
#else
DEFINE_EXCEPTION(g_SystemNS, TypeLoadException, false, COR_E_TYPELOAD)
#endif
DEFINE_EXCEPTION(g_SystemNS, TypeUnloadedException, false, COR_E_TYPEUNLOADED)
DEFINE_EXCEPTION(g_SystemNS, UnauthorizedAccessException, true, COR_E_UNAUTHORIZEDACCESS, CTL_E_PATHFILEACCESSERROR, STD_CTL_SCODE(335))
DEFINE_EXCEPTION(g_SecurityNS, VerificationException, false, COR_E_VERIFICATION)
DEFINE_EXCEPTION(g_InteropNS, COMException, false, E_FAIL)
DEFINE_EXCEPTION(g_InteropNS, ExternalException, false, E_FAIL)
DEFINE_EXCEPTION(g_InteropNS, SEHException, false, E_FAIL)
DEFINE_EXCEPTION(g_SystemNS, NotImplementedException, false, E_NOTIMPL)
DEFINE_EXCEPTION(g_SystemNS, OutOfMemoryException, false, E_OUTOFMEMORY, CTL_E_OUTOFMEMORY, STD_CTL_SCODE(31001))
DEFINE_EXCEPTION(g_SystemNS, ArgumentNullException, false, E_POINTER)
#define kLastExceptionInMscorlib kArgumentNullException
//
// All exceptions defined in other .NET Framework assemblies have to be at the end
//
#ifdef FEATURE_COMINTEROP
// Jupiter needs some HRESULTs mapped to exceptions in .NET Framework assemblies other than mscorlib.
DEFINE_EXCEPTION_IN_OTHER_FX_ASSEMBLY(g_MarkupNS, XamlParseException, "System.Runtime.WindowsRuntime.UI.Xaml", ECMA_PUBLICKEY_STR, false, E_XAMLPARSEFAILED)
DEFINE_EXCEPTION_IN_OTHER_FX_ASSEMBLY(g_AutomationNS, ElementNotAvailableException, "System.Runtime.WindowsRuntime.UI.Xaml", ECMA_PUBLICKEY_STR, false, E_ELEMENTNOTAVAILABLE)
DEFINE_EXCEPTION_IN_OTHER_FX_ASSEMBLY(g_AutomationNS, ElementNotEnabledException, "System.Runtime.WindowsRuntime.UI.Xaml", ECMA_PUBLICKEY_STR, false, E_ELEMENTNOTENABLED)
DEFINE_EXCEPTION_IN_OTHER_FX_ASSEMBLY(g_DirectUINS, LayoutCycleException, "System.Runtime.WindowsRuntime.UI.Xaml", ECMA_PUBLICKEY_STR, false, E_LAYOUTCYCLE)
#endif // FEATURE_COMINTEROP
// Please see comments on at the top of this list
#undef DEFINE_EXCEPTION
#undef DEFINE_EXCEPTION_HR_WINRT_ONLY
#undef DEFINE_EXCEPTION_IN_OTHER_FX_ASSEMBLY
|