PostSharp + Microsoft.Bcl.Async on .net 4.0

本文关键字:net on Async Microsoft Bcl PostSharp | 更新日期: 2023-09-27 18:36:18

我正在创建一个使用PostSharp 2.1 for AOP 的 .net 4.0 应用程序。
现在Microsoft.Bcl.Async是稳定的,我想在这个应用程序中使用async

但是,这样做时,我遇到了以下PostSharp问题:

PostSharp.Sdk.CodeModel.AssemblyLoadException: Cannot find assembly 'mscorlib, version=2.0.5.0, culture=neutral, publickeytoken=7cec85d7bea7798e'. [Public key mismatch] 
============ PostSharp Assembly Loading Log =================== 
LOG: Finding the assembly with binding identity 'mscorlib, version=2.0.5.0, culture=neutral, publickeytoken=7cec85d7bea7798e'. 
LOG: Probing location 'C:'Program Files (x86)'Reference Assemblies'Microsoft'Framework'.NETFramework'v4.0'mscorlib.dll' because this file was explicitly added to the search path. 
LOG: File 'C:'Program Files (x86)'Reference Assemblies'Microsoft'Framework'.NETFramework'v4.0'mscorlib.dll' has identity 'mscorlib, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089, processorarchitecture=msil'. 
LOG: File 'C:'Program Files (x86)'Reference Assemblies'Microsoft'Framework'.NETFramework'v4.0'mscorlib.dll' does not match the reference. 

仅当要编译的程序集引用System.ServiceModel并包含以下代码时,才会发生这种情况:

new FaultContractAttribute(typeof(SomeType));

我猜这与System.ServiceModel.FaultContractAttribute ctor上的[__DynamicallyInvokable]属性有关,它说:

"Performance critical to inline this type of method across NGen image boundaries".

有没有人遇到过同样的问题?

PostSharp + Microsoft.Bcl.Async on .net 4.0

PostSharp还不支持Microsoft.BCL(在撰写本文时,我们的版本是v3.0.38)。您可以在此处为该功能投票:https://postsharp.uservoice.com/forums/4949-general/suggestions/4225929-support-for-microsoft-bcl