Thursday, October 21, 2010

CLR 4.0 new content in abnormal state of confusion



Abnormal state of confusion

Some people call it Super exception. Refers not catch the exception, disrupting the process of the state, cause crashes, or do not want to see the process leading to behavior, like insanity. CLR4.0 not catch the exception made for a configurable processing mechanism. Consider the following procedure. In CLR2.0 years, this catch (Exception ex) of all possible exceptions are caught. In CLR4.0 where, by default, will not take effect this super catch, if abnormal will cause the program to stop.

class Program
(
static void Main (string [] args)
(
SaveFile ("file.txt");
Console.ReadLine ();
)
public static void SaveFile (string fileName)
(
try
(
FileStream fs = new FileStream (fileName, FileMode.Create);
)
catch (Exception ex)
(
Console.WriteLine ("File open error");
throw new IOException ();
)
)
)

Because of some special circumstances, need to change the default strategy. CLR 4.0 provides two means of customized

[HandleProcessCorruptedStateExceptions] method of labeling (Method attribute)

Methods need a super catch by adding the label. Take effect can make a super catch, as follows:


[HandleProcessCorruptedStateExceptions]
public static void SaveFile (string fileName)
(
try
(
FileStream fs = new FileStream (fileName, FileMode.Create);
)
catch (Exception ex)
(
Console.WriteLine ("File open error");
throw new IOException ();
)
)



Note: This form can only take effect within this method. In other places, or the default by CLR4.0 manner. config configuration file if you want to change this policy throughout the application level, the configuration file in config write




















Recommended links:



Fit, is the best



emerald may s birthstone facts And folklore



Auto Attendant computer Operator



XVID to WMV



Manufacturing integration trend manufacturing and EMS has Approaching



Wizard Audio CD Burners



Performance Evaluation Of 10 Folly



Knowledge need to update Staff training is not losing money "trading"



Set number format to solve such problems arise when



Report DICTIONARIES Education



MKV to Zune



Chongqing launched before the end of the first digital TV Village



How to add the equivalent in the R5 name (Alternate name)



AVI to DIVX



Recommend Firewall And Proxy Servers



No comments:

Post a Comment