Exception not found

Source: Internet
Author: User

In. Net 4.0, the exception level is handled. exceptions that cause system crashes cannot be eaten.

Specified upted state exceptions

Since 4.0, CLR will not take the initiative to throw you all exceptions. For those exceptions that it deems dangerous and may cause a process crash, it will be marked as uptedstateexception and handled by itself rather than thrownProgramSuch as accessviolationexception, which inherits from systemexception, will be treated as corruptedstateexception. However, it should be noted that only the exception type may be dangerous and the CLR will judge the owner of the thrown exception, if it finds that the access conflict is thrown by the operating system, it will be considered as a State crash exception, but if the exception is caused by the userCodeIf it is thrown, the CLR will not perform special processing on it, and it will still throw it normally as before.

1. If you want to compile the old code in. netframework4.0 but do not want to modify the code, configure the node: legacycorruptedstate -- exceptionspolicy = true

 

 

2 .. net4.0 adds a new namespace: system. runtime. exceptionservices, class handleprocesscorruptedstateexceptionsattribute. You only need to add this attribute to the corresponding method, and CLR will send you all the Exception Processing.

[Handledprocesscorruptedstateexceptions]

Public static int functionname ()

{

Try

{

// Code maybe throw exception

}

Catch (exception ex)

{

// Can get all the exception

}

}

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.