fileNotFound Assembly Netstandard 2.0 in 4.6.2 project

esben's Avatar

esben

05 Dec, 2017 09:55 AM

Hi
After having upgraded to Visual Studio 15.5 a previously working project compiling working with a binding/loading error from postsharp:

Sorry for the bad formatting, but i only have an email from a colleague who is experiencing the error.

Unhandled exception (postsharp-net40-x64-srv.exe release | .NET Framework 4.7.1):
PostSharp.Sdk.CodeModel.BindingException: Error while loading the type "Infosoft.S4.Aspects.Contracts.RequireUtcAttribute, Infosoft.S4.Aspects, Version=1.0.17.27, Culture=neutral, PublicKeyToken=null":
System.IO.FileLoadException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050)
Filnavn: netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
   ved System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)
   ved System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
   ved PostSharp.Sdk.CodeModel.AssemblyLoadHelper.^jJBt(Assembly _0, String _1, Boolean _2, Boolean _3)
WRN: Assembly binding logging is turned OFF.To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

===== Start of PostSharp Assembly Binder ===========================
Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050)
======Exception Details ============================================
LOG: Loading type Infosoft.S4.Aspects.Contracts.RequireUtcAttribute from assembly Infosoft.S4.Aspects, Version=1.0.17.27, Culture=neutral, PublicKeyToken=null.
LOG: (ClrHost) ProvideAssembly: "netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=amd64".
LOG: Finding runtime assembly with binding identity 'netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=amd64' in the Runtime context.
LOG: Found file 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll', identity='netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=msil', ProcessorArchitecture=MSIL.
LOG: Reference mismatch for 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll' [ProcessorArchitectureMismatch].
LOG: Post-policy assembly binding identity is: netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=amd64.
LOG: Looking in GAC for netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=amd64.
LOG: Found file 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll', identity='netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=msil', ProcessorArchitecture=MSIL.
LOG: Reference mismatch for 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll' [ProcessorArchitectureMismatch].
LOG: Found file 'C:\Users\havmunke\Source\Repos\SubscriptionService\Infosoft.S4.Subscriptions.Domain\bin\x64\Debug\net462\netstandard.dll', identity='netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=msil', ProcessorArchitecture=MSIL.
LOG: Reference mismatch for 'C:\Users\havmunke\Source\Repos\SubscriptionService\Infosoft.S4.Subscriptions.Domain\bin\x64\Debug\net462\netstandard.dll' [ProcessorArchitectureMismatch].
LOG: The assembly 'netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=amd64' was not found.
LOG: (ClrHost) ProvideAssembly: "netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=amd64": file not found!
LOG: (ClrHost) ProvideAssembly: "netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=msil".
LOG: Finding runtime assembly with binding identity 'netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=msil' in the Runtime context.
LOG: Found file 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll', identity='netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=msil', ProcessorArchitecture=MSIL.
LOG: Location found in resolved references: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll'.
LOG: Selecting file 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll' with identity 'netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=msil'.
LOG: (ClrHost) ProvideAssembly: "netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=msil": located in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\netstandard.dll".
LOG: (ClrHost) ProvideAssembly: "netstandard, version=2.0.0.0, culture=neutral, publickeytoken=cc7b13ffcd2ddd51, processorarchitecture=msil": returned successfully.
LOG: AssemblyLoadException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050)
====================================================================
       ved PostSharp.Sdk.CodeModel.AssemblyLoadHelper.^jJBt(Assembly _0, String _1, Boolean _2, Boolean _3)
       ved ^XJbqCOExOmCj.^NRQTI+sj(INamedType _0, BindingOptions _1)
       ved ^Mzw3\.bgGgRlJ.^cCM832sT[??0](Object _0, BindingOptions _1, ^d1u4kZd5aJLe _2)
       ved PostSharp.Sdk.CodeModel.TypeRefDeclaration.GetSystemType(Type[] genericTypeArguments, Type[] genericMethodArguments, BindingOptions options)
       ved PostSharp.Sdk.CodeModel.MethodRefDeclaration.^NqB3CEvX(Type[] _0, Type[] _1, BindingOptions _2)
       ved ^Mzw3\.bgGgRlJ.^cCM832sT[??0](Object _0, ^ezwsfuIx92Ld _1, ^bHXOWbqeB0HQ _2)
       ved ^Mzw3\.bgGgRlJ.^cCM832sT[??0](Object _0, GenericMap _1, Type[] _2, Type[] _3, BindingOptions _4, ^bHXOWbqeB0HQ _5)
       ved PostSharp.Sdk.CodeModel.MethodRefDeclaration.GetSystemMethod(Type[] genericTypeArguments, Type[] genericMethodArguments, BindingOptions bindingOptions)
       ved PostSharp.Sdk.CodeModel.CustomAttributeHelper.ConstructRuntimeObject(IAnnotationValue attribute, SerializedValueBindingOptions options)
       ved PostSharp.Sdk.AspectWeaver.AspectWeaverTask.Execute()   ved PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)   ved PostSharp.Sdk.Extensibility.Project.Execute()
       ved PostSharp.Hosting.PostSharpObject.ExecuteProjects()
       ved PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation).

The project is target .net 4.6.2 but one or more of the references is targeting .netstandard 2.0
Postsharp VS extension is 5.0.38 and postsharp nuget packages are 5.0.38. (We tried upgrading to .40 but same error).
The machine has .NET 4.7.1 installed

Apparently it looks like it might be the exact same issue as #4527 http://support.sharpcrafters.com/discussions/problems/4527-cant-bui...

The workaround described there does not work as there i no v7 folder in %ProgramData% and the v8 folder does not contain the same file/dll.

Any suggestions? As of now we are doing a restore of the machine with the previous visual studio version because it is blocking development for that specific user so we are unable to supply you with detailed reproductions (unfortunately).

  1. 1 Posted by esben on 06 Dec, 2017 11:20 AM

    esben's Avatar

    Any ideas on a workaround?

  2. Support Staff 2 Posted by PostSharp Techn... on 08 Dec, 2017 12:13 AM

    PostSharp Technologies's Avatar

    Hello,

    We have reproduced this issue locally and we're now looking for a workaround. I have also filed a separate bug for this case (#15703).
    We'll get back to you as soon as we have more information.

    -alex

  3. Support Staff 3 Posted by PostSharp Techn... on 10 Dec, 2017 09:43 PM

    PostSharp Technologies's Avatar

    Hello,

    the bug #15703 has been fixed in the current release of PostSharp 5.0.41.
    Should you need further help with this issue, don't hesitate to re-open this discussion.

    -alex

  4. PostSharp Technologies closed this discussion on 10 Dec, 2017 09:43 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac