views:

97

answers:

2
 [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]

I saw this attribute in the reflector for the base class libraries in .NET. Maybe immutable guarantees are supported internally?

+1  A: 

It has nothing to do with immutability, check the MSDN documentation

Thomas Levesque
+4  A: 

Read up about it here and here.

The short summary is that its instructing the runtime to guarantee execution of finally blocks in the face of any async exceptions (like ThreadAbortException).

The standard CLR host will hold off aborting thread while finally blocks are executing.

However, when SQL Server hosts the CLR is may trigger rude aborts which can happen while the CLR is running finally clauses. In these kind of cases, CERs are used to ensure state does not corrupt.

There are certain requirement you must meet inside CERs (For example, you are not allowed to box stuff inside a CER).

Sam Saffron
Thanks, can you tell me what's CER?
Joan Venge
CER = Constrained Execution Regions, make sure you read the doc on MSDN they cover this in much more detail.
Sam Saffron