简体   繁体   中英

Build with PostSharp Toolkit fails on 4.5.1 but works with 4.5

I have preserved a NuGet package of PostSharp.Toolkit.Threading, version 2.1.1.12, because I can't upgrade to version 3.x. Any project compiles fine, as long as I stay on .Net 4 or 4.5, but as soon as I change to 4.5.1 or 4.5.2, I get this error:

Error   3   error: Unhandled exception (2.1.7.35, 32 bit, CLR 2.0, Release): Cannot load assembly T:\WindowsFormsApplication4\packages\PostSharp.Toolkit.Threading.2.1.1.12\tools\PostSharp.Toolkit.Threading.Weaver.dll.
============ PostSharp Assembly Loading Log ===================
LOG:    NativeDotNetPlatform.LoadAssemblyFromFile: T:\WindowsFormsApplication4\packages\PostSharp.Toolkit.Threading.2.1.1.12\tools\PostSharp.Toolkit.Threading.Weaver.dll.
LOG:    Assembly identity returned by the host: postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil.
LOG:    Assembly 'postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil' is not yet loaded in the AppDomain.
LOG:    Invoking Assembly.Load({postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil})
LOG:    (ClrHost) ProvideAssembly: "postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil".
LOG:    Finding the assembly with binding identity 'postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil'.
LOG:    Location found from cache: 'T:\WindowsFormsApplication4\packages\PostSharp.Toolkit.Threading.2.1.1.12\tools\PostSharp.Toolkit.Threading.Weaver.dll'.
LOG:    (ClrHost) ProvideAssembly: "postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil": assembly found in search path.
LOG:    (ClrHost) ProvideAssembly: "postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil": located in "T:\WindowsFormsApplication4\packages\PostSharp.Toolkit.Threading.2.1.1.12\tools\PostSharp.Toolkit.Threading.Weaver.dll".
LOG:    (ClrHost) ProvideAssembly: "postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil": returned successfully.
LOG:    AssemblyLoadException: Could not load file or assembly 'postsharp.toolkit.threading.weaver, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
LOG:    Loaded: 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' from 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll'.
LOG:    Loaded: 'PostSharp.Hosting, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'T:\WindowsFormsApplication4\packages\PostSharp.2.1.7.35\tools\Release\PostSharp.Hosting.dll'.
LOG:    Loaded: 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' from 'C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll'.
LOG:    Loaded: 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' from 'C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll'.
LOG:    Loaded: 'PostSharp.Sdk, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'T:\WindowsFormsApplication4\packages\PostSharp.2.1.7.35\tools\Release\PostSharp.Sdk.dll'.
LOG:    Loaded: 'PostSharp.Settings, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'T:\WindowsFormsApplication4\packages\PostSharp.2.1.7.35\tools\Release\PostSharp.Settings.dll'.
LOG:    Loaded: 'PostSharp, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'T:\WindowsFormsApplication4\packages\PostSharp.2.1.7.35\tools\Release\PostSharp.dll'.
LOG:    Loaded: 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' from 'C:\Windows\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll'.
LOG:    Loaded: 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' from 'C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'.
LOG:    Loaded: 'PostSharp.Pipe, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'T:\WindowsFormsApplication4\packages\PostSharp.2.1.7.35\tools\Release\PostSharp.Pipe.dll'.
LOG:    Loaded: 'PostSharp.Sdk.XmlSerializers, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'T:\WindowsFormsApplication4\packages\PostSharp.2.1.7.35\tools\Release\PostSharp.Sdk.XmlSerializers.dll'.
=============================================================== See below for details.  T:\WindowsFormsApplication4\WindowsFormsApplication4\POSTSHARP  WindowsFormsApplication4

I can't figure out why this is happeneing. Any P# gurus out there?

The log shows that PostSharp hosting CLR version is 2.0. While loading the threading weaver assembly, CLR also attempts to load some dependency that requires CLR 4.0. This is when you get an exception.

PostSharp 2.x can recognize target framework 4.5 and automatically choose hosting CLR 4.0, however the newer framework version 4.5.1 is not recognized and CLR 2.0 is used by default.

You can override the hosting CLR by setting the MSBuild property PostSharpTargetFrameworkVersion to 4.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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