.net 4.0上的PostSharp + Microsoft.Bcl.Async

时间:2013-10-21 10:33:41

标签: c# postsharp

我正在创建一个使用PostSharp 2.1进行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));

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

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

是否有人遇到同样的问题?

1 个答案:

答案 0 :(得分:1)

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