A .NET 4 library that makes use of the Async Targeting Pack (ATP) and also marks itself as security transparent will fail to execute. The CLR throws an exception along the lines of:System.TypeLoadException was unhandled Message=Inheritance security rules violated while overriding member: 'ATPTest.Program+<DoWork>d__0.MoveNext()'. Security accessibility of the overriding method must match the security accessibility of the method being overriden. <snip>Running code analysis against the library results in warnings such as:CA2140 Transparent code must not reference security critical items Transparent method 'Class.DoSomethingAsync()' references security critical method 'AsyncTaskMethodBuilder<int>.Start<Class.<DoSomethingAsync>d__0>(ref Class.<DoSomethingAsync>d__0)'. In order for this reference to be allowed under the security transparency rules, either 'Class.DoSomethingAsync()' must become security critical or safe-critical, or 'AsyncTaskMethodBuilder<int>.Start<Class.<DoSomethingAsync>d__0>(ref Class.<DoSomethingAsync>d__0)' become security safe-critical or transparent.This problem also applies transitively to any application referencing the library. That is, if the library does NOT have SecurityTransparent applied but a host application references the library and itself has SecurityTransparent, the same problem occurs.
Visual Studio/Team Foundation Server/.NET Framework Tooling Version
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results