简体   繁体   English

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

[英]PostSharp + Microsoft.Bcl.Async on .net 4.0

I'm creating a .net 4.0 application which uses PostSharp 2.1 for AOP. 我正在创建一个使用PostSharp 2.1 for AOP的.net 4.0应用程序。
Now that Microsoft.Bcl.Async is stable, I'd like to use async in this application. 现在Microsoft.Bcl.Async稳定了,我想在此应用程序中使用async

However, when doing so, I'm running into the following PostSharp issue: 但是,这样做时,我遇到了以下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. 

This only happens when the assembly to be compiled references System.ServiceModel and contains the following code: 仅当要编译的程序集引用System.ServiceModel并包含以下代码时,才会发生这种情况:

new FaultContractAttribute(typeof(SomeType));

I'm guessing that this has something to do with the [__DynamicallyInvokable] attribute on the System.ServiceModel.FaultContractAttribute ctor , which says: 我猜想这与System.ServiceModel.FaultContractAttribute ctor上的[__DynamicallyInvokable]属性有关,该属性说:

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

Has anybody ran into the same issue? 有人遇到过同样的问题吗?

Microsoft.BCL is not supported yet by PostSharp (we are at v3.0.38 at the time of writing). PostSharp尚不支持Microsoft.BCL(在撰写本文时,我们的版本是v3.0.38)。 You can vote for the feature here: https://postsharp.uservoice.com/forums/4949-general/suggestions/4225929-support-for-microsoft-bcl 您可以在此处对该功能进行投票: https : //postsharp.uservoice.com/forums/4949-general/suggestions/4225929-support-for-microsoft-bcl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM