2

When I add Postsharp (5.0.44) to one of my project, I get this error when compile it, after checking I see Postsharp has problem with Unity (v4.0.30319), updated Unity to version 5 and problem solved, but another problem is my other project using Prism.Wpf (v6) and this lib is not compatible with Unity v5, so I get deadlock now. Actually I got same error ("Ambiguous assembly binding policies") before with Prism.Core (v6) but solved with v7.

Because I'm using 3 libs and they don't work together so I don't know where I should raise issue ticket, then I just ask if there is any workaround.

By the way, my projects use .Net Framework 4.6.1.

Here is full log

Severity    Code    Description Project File    Line    Suppression State
Error       Unhandled exception (postsharp-net40-x86-srv.exe release | .NET Framework 4.7.1): 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.2.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).
kvuong
  • 485
  • 3
  • 20
  • Could you please try PostSharp 5.1 preview? We did major changes to assembly binding which were not possible to deliver as a bug fix. I understand that using a preview version may not be an option for you, but we would appreciate to know whether the new version fixes your issue. – Daniel Balas Mar 06 '18 at 12:52
  • @DanielBalas Hi, it get "Error connecting to the pipe server. See previous warnings for details" error now, checking Warnings then I see these message: "Retrying to execute the pipe server" and "Connection unexpectedly closed by the server". – kvuong Mar 07 '18 at 03:11
  • This is usually solvable by running the compilation under admin privileges and/or restarting your machine. – Daniel Balas Mar 08 '18 at 08:24
  • @DanielBalas I run Visual Studio with Admin right and still get that error. – kvuong Mar 13 '18 at 05:15
  • 1
    Possible duplicate of [Cannot use PostSharp with .NET 4.6.2](https://stackoverflow.com/questions/42847947/cannot-use-postsharp-with-net-4-6-2) – Michael Freidgeim Apr 23 '19 at 13:29

0 Answers0