![]() CATEGORIES: BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism |
Nbsp; FCL-Defined Exception ClassesThe Framework Class Library (FCL) defines many exception types (all ultimately derived from System. Exception). The following hierarchy shows the exception types defined in the MSCorLib.dll assem- bly; other assemblies define even more exception types. (The application used to obtain this hierarchy is shown in Chapter 23, “Assembly Loading and Reflection.”)
System.Exception System.AggregateException System.ApplicationException System.Reflection.InvalidFilterCriteriaException System.Reflection.TargetException System.Reflection.TargetInvocationException System.Reflection.TargetParameterCountException System.Threading.WaitHandleCannotBeOpenedException System.Diagnostics.Tracing.EventSourceException System.InvalidTimeZoneException System.IO.IsolatedStorage.IsolatedStorageException System.Threading.LockRecursionException System.Runtime.CompilerServices.RuntimeWrappedException System.SystemException System.Threading.AbandonedMutexException System.AccessViolationException System.Reflection.AmbiguousMatchException System.AppDomainUnloadedException System.ArgumentException System.ArgumentNullException System.ArgumentOutOfRangeException System.Globalization.CultureNotFoundException System.Text.DecoderFallbackException System.DuplicateWaitObjectException System.Text.EncoderFallbackException System.ArithmeticException System.DivideByZeroException System.NotFiniteNumberException System.OverflowException System.ArrayTypeMismatchException System.BadImageFormatException System.CannotUnloadAppDomainException System.ContextMarshalException System.Security.Cryptography.CryptographicException System.Security.Cryptography.CryptographicUnexpectedOperationException System.DataMisalignedException System.ExecutionEngineException System.Runtime.InteropServices.ExternalException System.Runtime.InteropServices.COMException System.Runtime.InteropServices.SEHException System.FormatException System.Reflection.CustomAttributeFormatException System.Security.HostProtectionException System.Security.Principal.IdentityNotMappedException System.IndexOutOfRangeException System.InsufficientExecutionStackException System.InvalidCastException System.Runtime.InteropServices.InvalidComObjectException System.Runtime.InteropServices.InvalidOleVariantTypeException System.InvalidOperationException System.ObjectDisposedException System.InvalidProgramException System.IO.IOException System.IO.DirectoryNotFoundException System.IO.DriveNotFoundException System.IO.EndOfStreamException System.IO.FileLoadException System.IO.FileNotFoundException System.IO.PathTooLongException System.Collections.Generic.KeyNotFoundException System.Runtime.InteropServices.MarshalDirectiveException System.MemberAccessException System.FieldAccessException System.MethodAccessException System.MissingMemberException System.MissingFieldException System.MissingMethodException System.Resources.MissingManifestResourceException System.Resources.MissingSatelliteAssemblyException System.MulticastNotSupportedException System.NotImplementedException System.NotSupportedException System.PlatformNotSupportedException System.NullReferenceException System.OperationCanceledException System.Threading.Tasks.TaskCanceledException System.OutOfMemoryException System.InsufficientMemoryException System.Security.Policy.PolicyException System.RankException System.Reflection.ReflectionTypeLoadException System.Runtime.Remoting.RemotingException System.Runtime.Remoting.RemotingTimeoutException System.Runtime.InteropServices.SafeArrayRankMismatchException System.Runtime.InteropServices.SafeArrayTypeMismatchException System.Security.SecurityException System.Threading.SemaphoreFullException System.Runtime.Serialization.SerializationException System.Runtime.Remoting.ServerException System.StackOverflowException System.Threading.SynchronizationLockException System.Threading.ThreadAbortException System.Threading.ThreadInterruptedException System.Threading.ThreadStartException System.Threading.ThreadStateException System.TimeoutException System.TypeInitializationException System.TypeLoadException System.DllNotFoundException System.EntryPointNotFoundException System.TypeAccessException System.TypeUnloadedException System.UnauthorizedAccessException System.Security.AccessControl.PrivilegeNotHeldException System.Security.VerificationException System.Security.XmlSyntaxException System.Threading.Tasks.TaskSchedulerException System.TimeZoneNotFoundException
The original idea was that System.Exception would be the base type for all exceptions and that two other types, System.SystemException and System.ApplicationException, would be the only two types immediately derived from Exception. Furthermore, exceptions thrown by the CLR would be derived from SystemException, and all application-thrown exceptions would be derived from ApplicationException. This way, developers could write a catch block that catches all CLR- thrown exceptions or all application-thrown exceptions. However, as you can see, this rule was not followed very well; some exception types are immedi- ately derived from Exception (IsolatedStorageException), some CLR-thrown exceptions are de- rived from ApplicationException (TargetInvocationException), and some application-thrown exceptions are derived from SystemException (FormatException). So it is all a big mess, and the result is that the SystemException and ApplicationException types have no special meaning at all. At this point, Microsoft would like to remove them from the exception class hierarchy, but they can’t because it would break any code that already references these two types.
Date: 2016-03-03; view: 808
|