无法将 PostSharp 与 .NET 4.6.2 一起使用
Cannot use PostSharp with .NET 4.6.2
我正在使用 PostSharp,并且刚刚将我的解决方案升级到 .NET 4.6.2
安装包后 System.ValueTuple
我在尝试构建启用了 PostSharp 的主项目时在输出中收到 BindingException: 不明确的程序集绑定策略 异常。
Unhandled exception (4.3.30.0, postsharp-net40-x86-srv.exe, CLR 4.0.30319.394802, Release): PostSharp.Sdk.CodeModel.BindingException: Ambiguous assembly binding policies: Assembly 'system.runtime, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a' redirects both to 'system.runtime, version=4.1.1.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a' and 'system.runtime, version=4.0.20.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a'.
at PostSharp.Sdk.CodeModel.AssemblyBindingPolicyManager.EvaluatePolicy(IAssemblyName assemblyName, Boolean evaluateSystemPolicies)
at PostSharp.Sdk.CodeModel.CompareExtensions.^4+F3cylo(IAssemblyName _0, IAssemblyName _1, AssemblyBindingPolicyManager _2, BindingOptions _3, Boolean _4)
at PostSharp.Sdk.CodeModel.ModuleDeclaration.FindAssembly(IAssemblyName assemblyName, BindingOptions bindingOptions)
at PostSharp.Sdk.CodeModel.ModuleDeclaration.^nQbUijLO(String _0, IAssemblyName _1, BindingOptions _2)
at PostSharp.Sdk.CodeModel.ModuleDeclaration.FindType(Type reflectionType, BindingOptions bindingOptions)
at PostSharp.Sdk.CodeModel.DeclarationCache.^pFnf8wEt()
at PostSharp.Sdk.CodeModel.TypeRefDeclaration.get_TypeIdentifier()
at PostSharp.Sdk.CodeModel.CompareExtensions.DefinitionMatchesReference(INamedType definition, INamedType reference, BindingOptions options)
at PostSharp.Sdk.CodeModel.TypeRefDeclaration.^A9yFoe2uB3TC(ITypeSignature _0, BindingOptions _1)
at PostSharp.Sdk.CodeModel.TypeRefDeclaration.MatchesReference(ITypeSignature reference)
at PostSharp.Sdk.CodeModel.Collections.CustomAttributeDeclarationCollection.Contains(IType type)
at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^SgrhoGlQ(AssemblyRefDeclaration _0)
at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^+GwnKh4ZYHu3()
at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.Execute()
at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
at PostSharp.Sdk.Extensibility.Project.Execute()
at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation).
这是我的 Web.config
中的相关绑定重定向
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
</dependentAssembly>
这可以通过升级到 PostSharp 5.0 预览版来解决
https://www.nuget.org/packages/PostSharp/5.0.21-preview
https://www.postsharp.net/downloads/postsharp-5.0
我正在使用 PostSharp,并且刚刚将我的解决方案升级到 .NET 4.6.2
安装包后 System.ValueTuple
我在尝试构建启用了 PostSharp 的主项目时在输出中收到 BindingException: 不明确的程序集绑定策略 异常。
Unhandled exception (4.3.30.0, postsharp-net40-x86-srv.exe, CLR 4.0.30319.394802, Release): PostSharp.Sdk.CodeModel.BindingException: Ambiguous assembly binding policies: Assembly 'system.runtime, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a' redirects both to 'system.runtime, version=4.1.1.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a' and 'system.runtime, version=4.0.20.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a'.
at PostSharp.Sdk.CodeModel.AssemblyBindingPolicyManager.EvaluatePolicy(IAssemblyName assemblyName, Boolean evaluateSystemPolicies)
at PostSharp.Sdk.CodeModel.CompareExtensions.^4+F3cylo(IAssemblyName _0, IAssemblyName _1, AssemblyBindingPolicyManager _2, BindingOptions _3, Boolean _4)
at PostSharp.Sdk.CodeModel.ModuleDeclaration.FindAssembly(IAssemblyName assemblyName, BindingOptions bindingOptions)
at PostSharp.Sdk.CodeModel.ModuleDeclaration.^nQbUijLO(String _0, IAssemblyName _1, BindingOptions _2)
at PostSharp.Sdk.CodeModel.ModuleDeclaration.FindType(Type reflectionType, BindingOptions bindingOptions)
at PostSharp.Sdk.CodeModel.DeclarationCache.^pFnf8wEt()
at PostSharp.Sdk.CodeModel.TypeRefDeclaration.get_TypeIdentifier()
at PostSharp.Sdk.CodeModel.CompareExtensions.DefinitionMatchesReference(INamedType definition, INamedType reference, BindingOptions options)
at PostSharp.Sdk.CodeModel.TypeRefDeclaration.^A9yFoe2uB3TC(ITypeSignature _0, BindingOptions _1)
at PostSharp.Sdk.CodeModel.TypeRefDeclaration.MatchesReference(ITypeSignature reference)
at PostSharp.Sdk.CodeModel.Collections.CustomAttributeDeclarationCollection.Contains(IType type)
at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^SgrhoGlQ(AssemblyRefDeclaration _0)
at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^+GwnKh4ZYHu3()
at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.Execute()
at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
at PostSharp.Sdk.Extensibility.Project.Execute()
at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation).
这是我的 Web.config
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
</dependentAssembly>
这可以通过升级到 PostSharp 5.0 预览版来解决
https://www.nuget.org/packages/PostSharp/5.0.21-preview https://www.postsharp.net/downloads/postsharp-5.0