C#常见的异常

.NET

System.Exception
//所有异常的基类型

System.ApplicationException
//发生非致命应用程序错误时引发的异常

System.SystemException
//为System命名空间中的预定义异常定义基类

System.SystemException
//异常根类

System.AccessViolationException
//在试图读写受保护内存时引发的异常

System.ArgumentException
//在向方法提供的其中一个参数无效时引发的异常

System.Collections.Generic.KeyNotFoundException
//指定用于访问集合中元素的键与集合中的任何键都不匹配时所引发的异常

System.IndexOutOfRangeException
//访问数组时,因元素索引超出数组边界而引发的异常

System.InvalidCastException
//因无效类型转换或显示转换引发的异常

System.InvalidOperationException
//当方法调用对于对象的当前状态无效时引发的异常

System.InvalidProgramException
//当程序包含无效Microsoft中间语言(MSIL)或元数据时引发的异常,这通常表示生成程序的编译器中有bug

System.IO.IOException
//发生I/O错误时引发的异常

System.NotImplementedException
//在无法实现请求的方法或操作时引发的异常

System.NullReferenceException
//尝试对空对象引用进行操作时引发的异常

System.OutOfMemoryException
//没有足够的内存继续执行程序时引发的异常

System.StackOverflowException
//挂起的方法调用过多而导致执行堆栈溢出时引发的异常

System.ArgumentException
//参数异常

System.ArgumentNullException
//当将空引用传递给不接受它作为有效参数的方法时引发的异常

System.ArgumentOutOfRangeException
//当参数值超出调用的方法所定义的允许取值范围时引发的异常

System.ArithmeticException
//算术异常

System.DivideByZeroException
//试图用零除整数值或十进制数值时引发的异常

System.NotFiniteNumberException
//当浮点值为正无穷大、负无穷大或非数字(NaN)时引发的异常

System.OverflowException
//在选中的上下文中所进行的算数运算、类型转换或转换操作导致溢出时引发的异常

System.IOException
//派生的异常类型

System.IO.DirectoryNotFoundException
//当找不到文件或目录的一部分时所引发的异常

System.IO.DriveNotFoundException
//当尝试访问的驱动器或共享不可用时引发的异常

System.IO.EndOfStreamException
//读操作试图超出流的末尾时引发的异常

System.IO.FileLoadException
//当找到托管程序却不能加载它时引发的异常

System.IO.FileNotFoundException
//试图访问磁盘上不存在的文件失败时引发的异常

System.IO.PathTooLongException
//当路径名或文件名超过系统定义的最大长度时引发的异常

ArrayTypeMismatchException
//试图在数组中存储错误类型的对象

BadImageFormatException
//格式错误异常,如32位应用访问64位系统Dll引起

DivideByZeroException
//除零异常

DllNotFoundException
//找不到引用的dll

FormatException
//参数格式错误

MethodAccessException
//试图访问私有或者受保护的方法

MissingMemberException
//访问一个无效版本的dll

NotSupportedException
//调用的方法在类中没有实现

PlatformNotSupportedException
//平台不支持某个特定属性时抛出该错误

ArgumentException 
//参数异常

ArgumentNullException
//空参数异常

ArgumentOutOfRangeException
//参数值超出范围 

ArithmeticException
//算术异常
 
ArrayTypeMismatchException
//类型不匹配异常
 
IndexOutOfRangeException 
//索引超出范围异常

InvalidcastException
//不正确的类型转换异常 

InvalidOperationException 
//不正确的操作异常
 
MethodAccessException
//方法访问异常

MissingMemberException
//丢失成员异常

NotFiniteNumberException
//无穷大数字异常
 
NotSupportedException
//操作不支持异常

NullReferenceException
//空引用异常,如调用没有实例化的对象的成员

OutOfMemoryException
//内存空间不够
 
PlatformNotSupportedException
//平台不支持某个特定属性时抛出该错误 

StackOverflowException
//堆栈溢出

  

猜你喜欢

转载自www.cnblogs.com/lizewang/p/9259192.html