C # Common exceptions

Source: Internet
Author: User
C # Different exception types in the processing ., memberaccessexception access error: type members cannot be accessed argumentexception parameter error: Invalid method parameter argumentnullexception parameter is null: an unacceptable null parameter arithmeticexception is passed to the method. calculation error: exceptions caused by mathematical operations have a wide coverage. The arraytypemismatchexception array type does not match dividebyzeroexception. The format of the zero division formatexception parameter is incorrect. The indexoutofrangeexception index is out of the range. It is less than 0 or greater than the index of the last element, multicast not supported by multicastnotsupportedexception is triggered when the explicit conversion fails: the method that triggers notsupportedexception call when two non-empty delegation fails to be combined. If nullreferenceexception is not implemented in the class, when a null referenced object is referenced, outofmemoryexception is thrown and the memory cannot be allocated for the new statement, insufficient memory overflowexception overflow stackoverflowexception Stack Overflow typeinitialization Initialization type of exception error: the notfinitenumberexception value is infinitely large when the static constructor has a problem: the number is invalid. What is an exception? The exception is a program execution error. Causes of exceptions: 1. Code errors, including syntax errors, logic errors, and resource unavailability, which are errors caused by unauthorized resource access by the system. Iii. Common Language Runtime Library, which is caused by internal CLR errors. The exception class exception provides a lot of methods to capture and handle exceptions. There are two types of exception handling encapsulated in the exception class: 1. Exceptions caused by user program execution are derived from the applicationexception class. 2. The other is an exception caused by a common language runtime, derived from the systemexception class. Common exception type: systemexception: Provides the difference between system exceptions and application exceptions. Argumentexception: this exception is thrown when any parameter provided by the method is invalid. Arithmeticexception: this exception indicates an error caused by arithmetic operations. Dataexception: this exception is thrown if an error is generated when the ADO. NET component is used. Formatexception: this exception is thrown when the format of the parameter does not conform to the parameter specifications of the called method. Ioexception: this exception is thrown when an I/O error occurs. Indexoutofrangeexception: this exception is thrown when an index outside the array boundary is attempted to access the elements of the array. Argumentnullexception: this exception is thrown when a null reference is passed to a method with an invalid parameter. Overflowexception: this exception is thrown when the arithmetic operation result is large and cannot be expressed by the target type. Dividebyzeroexception: this exception is thrown when an attempt is made to divide the number by zero. Applicationexception: an application-defined exception is detected during application execution. Targetexception: this exception is thrown when an invalid target is attempted. Arrayindexoutofboundsexception: the array size is smaller than or greater than the actual array size. Nullpointerexception: attempts to access a null object member. Classnotfoundexception: the required class cannot be loaded. Inputmismatchexception: The expected data type does not match the actual input data type. Illegalargumentexception: The method accepts invalid parameters. Common attribute of the exception class: Message: provides detailed information about the exception. Source: The name of the application or object that causes an exception. Stacktrace: This attribute provides detailed information about the methods called on the stack, and displays the recently called methods first. Innerexception: a reference to an internal exception. If this exception is based on the previous exception, an internal exception refers to the initial exception. C # common error handling 1. Exceptions caused by argumentexception when one of the parameters provided to the method is invalid 2. Exceptions caused by appdomainunloadedexception when trying to access the uninstalled application domain 3. arithmeticexception due to arithmetic operations exception caused by errors in type conversion or conversion operations 4 arraytypemismatchexception exception 5 badimageformatexception when trying to store incorrect elements in the array exception caused by invalid value 6 exception caused by failed attempts to uninstall the application domain 7 codedomserializerexception exception caused by serialization error 8 licenseexception indicates that the component cannot be licensed exception 9 warni Ngexception specifies to press warning (rather than error) exception 10 thrown when an error occurs in the configurationexception configuration 11 contextconfiguralexception 12 contextconfiguralexception is thrown when an error occurs in the installation commit, rollback, or uninstallation phase exception thrown when the context boundary fails. 13 dataexception indicates that ADO is used. 14 dbconcurrencyexception caused by an error in the net component during the update operation the number of affected rows is equal to zero, 15 sqlexception exceptions caused by dataadapter when SQL Server Returns a warning or error. Unable to inherit from this class 16 invalidprinterexception indicates the exception 17 registrationexception thrown when trying to access the printer with invalid printer settings when detecting a registration error 18 formatexception when the parameter format does not conform to the called exception 19 caused by indexoutofrangeexception when trying to access an array element whose index exceeds the limit of the array 20 invalidcastexception caused by invalid type conversion or explicit conversion 21 invalidoperationexception when the method exception 22 caused by internalbufferoverflowexception internal buffer overflow 23 ioexception 24 managementexception indicates a management exception 25 notimplementedexception exception caused by notimplementedexception when the requested method or operation cannot be implemented 26 notsupportedexception when the called method is not supported, or an exception 27 nullreferenceexception is thrown when you try to read, find, or write a stream that does not support calling the function to cancel the reference of a null object. 28 outofmemoryexception There is not enough memory to continue executing the program. Exception 29 rankexception: An array with incorrect number of dimensions is passed to the method. Exception 30 ambiguousmatchexception when the operation bound to the method leads to more than one method. 31 reflectiontypeloadexception caused by matching the binding criteria when any class in the module cannot be loaded by the module. 32 serverexception thrown by the gettypes method when a client connection fails to cause an exception. net Framework application, exceptions thrown to deliver errors to the client 33 policyexception exceptions thrown when the policy disables code execution 34 securityexception exceptions thrown when security errors are detected 35 xmlsyntaxexception syntax errors occur in XML syntax analysis exception 36 timeoutexception when the specified Timeout time has been reached 37 synchronizationlockexception when the synchronous method is called from the non-Synchronous Code Block 38 threadabortexception In the abort Method exception 39 typeinitializationexception caused by exception 39 typeinitializationexception caused by exception surrounding the exception caused by the class Initial Value Setting item 40 typeloadexception occurs when loading failure 41 typeunloadedexception tries to access the uninstalled class exception 42 unauthorizedaccessexception: An exception occurs when the operating system rejects access due to an I/o error or a specified type of security Error 43 soapexception when the XML Web Services method is called through soap and an exception occurs exception 44 xmlschemaexception returned detailed information about the architecture exception 45 xmlexception returned detailed information about the last exception 46 explain texception due to processing the "extensible style sheet language" (XSL) exception caused by an error during conversion 47 xpathexception when an error occurs while processing the XPath expression

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.