[CSHARP-2944] Check uses of ConstrainedExecution and ReliabilityContract when targetting netstandard2.0 Created: 07/Feb/20  Updated: 11/May/21  Resolved: 11/May/21

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Robert Stam Assignee: Mikalai Mazurenka (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Enable features that can now be supported when targetting netstandard2.0

 Comments   
Comment by Mikalai Mazurenka (Inactive) [ 10/May/21 ]

The Constrained Execution Regions are only supported in .NET Framework (MSDN: CER).
CER delineates a region of code where "out-of-band" exceptions (ThreadAbortException, OutOfMemoryException, StackOverflowException) cannot be thrown. This feature mostly exists for SQL in-process hosting CLR and in our code it is used as an additional layer of safety when disposing unmanaged resources.
Regarding usage in targets other than net452 with regard to exceptions thrown:

  • The ThreadAbortException is not supported in .NET Standard and is not available in .NET 5 and .NET Core: MSDN: Thread.Abort Method.
  • Other exceptions can still be thrown within CER in targets other than net452.

As a summary, nothing could be done in scope of this ticket, since the code to support CER is already at place for net452 and is not available for other targets.

Comment by Robert Stam [ 07/Feb/20 ]

Check RuntimeHelpers.PrepareConstrainedRegions also.

Generated at Wed Feb 07 21:43:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.