I'm creating a .net 4.0 application which uses PostSharp
2.1 for AOP.
Now that Microsoft.Bcl.Async is stable, I'd like to use async
in this application.
However, when doing so, I'm running into the following PostSharp
issue:
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:
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:
"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). You can vote for the feature here: https://postsharp.uservoice.com/forums/4949-general/suggestions/4225929-support-for-microsoft-bcl