+ const int COR_E_OVERFLOW = unchecked ((int)0x80131516L);
+ const int COR_E_PATHTOOLONG = unchecked ((int)0x800700CEL);
+ const int ERROR_FILENAME_EXCED_RANGE = unchecked ((int)0xCE);
+ const int COR_E_RANK = unchecked ((int)0x80131517L);
+ const int COR_E_REFLECTIONTYPELOAD = unchecked ((int)0x80131602L);
+ const int COR_E_REMOTING = unchecked ((int)0x8013150BL);
+ const int COR_E_SAFEARRAYTYPEMISMATCH = unchecked ((int)0x80131533L);
+ const int COR_E_SECURITY = unchecked ((int)0x8013150AL);
+ const int COR_E_SERIALIZATION = unchecked ((int)0x8013150CL);
+ const int COR_E_STACKOVERFLOW = unchecked ((int)0x800703E9L);
+ const int ERROR_STACK_OVERFLOW = unchecked ((int)0x03E9);
+ const int COR_E_SYNCHRONIZATIONLOCK = unchecked ((int)0x80131518L);
+ const int COR_E_SYSTEM = unchecked ((int)0x80131501L);
+ const int COR_E_TARGET = unchecked ((int)0x80131603L);
+ const int COR_E_TARGETINVOCATION = unchecked ((int)0x80131604L);
+ const int COR_E_TARGETPARAMCOUNT = unchecked ((int)0x8002000EL);
+ const int COR_E_THREADABORTED = unchecked ((int)0x80131530L);
+ const int COR_E_THREADINTERRUPTED = unchecked ((int)0x80131519L);
+ const int COR_E_THREADSTATE = unchecked ((int)0x80131520L);
+ const int COR_E_THREADSTOP = unchecked ((int)0x80131521L);
+ const int COR_E_TYPEINITIALIZATION = unchecked ((int)0x80131534L);
+ const int COR_E_VERIFICATION = unchecked ((int)0x8013150DL);
+ //const int COR_E_WEAKREFERENCE = unchecked ((int)?);
+ //const int COR_E_VTABLECALLSNOTSUPPORTED = unchecked ((int));
+
+ switch (errorCode) {
+ case MSEE_E_APPDOMAINUNLOADED:
+ return new AppDomainUnloadedException ();
+ case COR_E_APPLICATION:
+ return new ApplicationException ();
+ case E_INVALIDARG:
+ return new ArgumentException ();
+ case COR_E_ARGUMENTOUTOFRANGE:
+ return new ArgumentOutOfRangeException ();
+ case COR_E_ARITHMETIC:
+ return new ArithmeticException ();
+ case COR_E_ARRAYTYPEMISMATCH:
+ return new ArrayTypeMismatchException ();
+ case COR_E_BADIMAGEFORMAT:
+ case ERROR_BAD_FORMAT:
+ return new BadImageFormatException ();
+// case COR_E_COMEMULATE_ERROR:
+// return new COMEmulateException ();
+ case COR_E_CONTEXTMARSHAL:
+ return new ContextMarshalException ();
+// case COR_E_CORE:
+// return new CoreException ();
+ case NTE_FAIL:
+ return new System.Security.Cryptography.CryptographicException ();
+ case COR_E_DIRECTORYNOTFOUND:
+ case ERROR_PATH_NOT_FOUND:
+ return new System.IO.DirectoryNotFoundException ();
+ case COR_E_DIVIDEBYZERO:
+ return new DivideByZeroException ();
+ case COR_E_DUPLICATEWAITOBJECT:
+ return new DuplicateWaitObjectException ();
+ case COR_E_ENDOFSTREAM:
+ return new System.IO.EndOfStreamException ();
+ case COR_E_EXCEPTION:
+ return new Exception ();
+ case COR_E_EXECUTIONENGINE:
+ return new ExecutionEngineException ();
+ case COR_E_FIELDACCESS:
+ return new FieldAccessException ();
+ case COR_E_FILENOTFOUND:
+ case ERROR_FILE_NOT_FOUND:
+ return new System.IO.FileNotFoundException ();
+ case COR_E_FORMAT:
+ return new FormatException ();
+ case COR_E_INDEXOUTOFRANGE:
+ return new IndexOutOfRangeException ();
+ case COR_E_INVALIDCAST:
+ // E_NOINTERFACE has same value as COR_E_INVALIDCAST
+ return new InvalidCastException ();
+ case COR_E_INVALIDCOMOBJECT:
+ return new InvalidComObjectException ();
+ case COR_E_INVALIDFILTERCRITERIA:
+ return new InvalidFilterCriteriaException ();
+ case COR_E_INVALIDOLEVARIANTTYPE:
+ return new InvalidOleVariantTypeException ();
+ case COR_E_INVALIDOPERATION:
+ return new InvalidOperationException ();
+ case COR_E_IO:
+ return new System.IO.IOException ();
+ case COR_E_MEMBERACCESS:
+ return new MemberAccessException ();
+ case COR_E_METHODACCESS:
+ return new MethodAccessException ();
+ case COR_E_MISSINGFIELD:
+ return new MissingFieldException ();
+ case COR_E_MISSINGMANIFESTRESOURCE:
+ return new System.Resources.MissingManifestResourceException ();
+ case COR_E_MISSINGMEMBER:
+ return new MissingMemberException ();
+ case COR_E_MISSINGMETHOD:
+ return new MissingMethodException ();
+ case COR_E_MULTICASTNOTSUPPORTED:
+ return new MulticastNotSupportedException ();
+ case COR_E_NOTFINITENUMBER:
+ return new NotFiniteNumberException ();
+ case E_NOTIMPL:
+ return new NotImplementedException ();
+ case COR_E_NOTSUPPORTED:
+ return new NotSupportedException ();
+ case COR_E_NULLREFERENCE:
+ // E_POINTER has the same value as COR_E_NULLREFERENCE
+ return new NullReferenceException ();
+ case E_OUTOFMEMORY:
+ // COR_E_OUTOFMEMORY has the same value as E_OUTOFMEMORY
+ return new OutOfMemoryException ();
+ case COR_E_OVERFLOW:
+ return new OverflowException ();
+ case COR_E_PATHTOOLONG:
+ case ERROR_FILENAME_EXCED_RANGE:
+ return new System.IO.PathTooLongException ();
+ case COR_E_RANK:
+ return new RankException ();
+ case COR_E_REFLECTIONTYPELOAD:
+ return new System.Reflection.ReflectionTypeLoadException (new Type[] { }, new Exception[] { });
+ case COR_E_REMOTING:
+ return new System.Runtime.Remoting.RemotingException ();
+ case COR_E_SAFEARRAYTYPEMISMATCH:
+ return new SafeArrayTypeMismatchException ();
+ case COR_E_SECURITY:
+ return new SecurityException ();
+ case COR_E_SERIALIZATION:
+ return new System.Runtime.Serialization.SerializationException ();
+ case COR_E_STACKOVERFLOW:
+ case ERROR_STACK_OVERFLOW:
+ return new StackOverflowException ();
+ case COR_E_SYNCHRONIZATIONLOCK:
+ return new SynchronizationLockException ();
+ case COR_E_SYSTEM:
+ return new SystemException ();
+ case COR_E_TARGET:
+ return new TargetException ();
+ case COR_E_TARGETINVOCATION:
+ return new System.Reflection.TargetInvocationException (null);
+ case COR_E_TARGETPARAMCOUNT:
+ return new TargetParameterCountException ();
+// case COR_E_THREADABORTED:
+// ThreadAbortException c'tor is inaccessible
+// return new System.Threading.ThreadAbortException ();
+ case COR_E_THREADINTERRUPTED:
+ return new ThreadInterruptedException ();
+ case COR_E_THREADSTATE:
+ return new ThreadStateException ();
+// case COR_E_THREADSTOP:
+// ThreadStopException does not exist
+// return new System.Threading.ThreadStopException ();
+ case COR_E_TYPELOAD:
+ return new TypeLoadException ();
+ // MSDN lists COR_E_TYPELOAD twice with different exceptions.
+ // return new EntryPointNotFoundException ();
+ case COR_E_TYPEINITIALIZATION:
+ return new TypeInitializationException("", null);
+ case COR_E_VERIFICATION:
+ return new VerificationException ();
+// case COR_E_WEAKREFERENCE:
+// return new WeakReferenceException ();
+// case COR_E_VTABLECALLSNOTSUPPORTED:
+// return new VTableCallsNotSupportedException ();