In Asp.Net Core solution targeted to 4.6.1 full Framework I am using 2.1.1 Microsoft.Azure.ActiveDirectory.GraphClient.dll
In MSTest tests library TestMethods I am getting exception:
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Data.Services.Client, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The wild thing that nuspec requires version 5.6.4, but DLL actually references 5.6.3.
Extract from dotPeek:
// Assembly Microsoft.Azure.ActiveDirectory.GraphClient, Version=2.1.10.0, Culture=neutral, PublicKeyToken=null
// Assembly references:
// Microsoft.Data.Services.Client, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// Microsoft.Data.Edm, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// Microsoft.Data.OData, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
.nuget\packages\Microsoft.Azure.ActiveDirectory.GraphClient\2.1.1\Microsoft.Azure.ActiveDirectory.GraphClient.nuspec
<dependencies>
<dependency id="Microsoft.Data.Services.Client" version="5.6.4" />
<dependency id="Microsoft.Data.Edm" version="5.6.4" />
<dependency id="Microsoft.Data.OData" version="5.6.4" />
<dependency id="System.Spatial" version="5.6.4" />
</dependencies>
I've tried to install Microsoft.Data.Services.Client 5.6.3, but NuGet reported that Microsoft.Data.Odata requires 5.6.4
I've tried to install Microsoft.Data.Odata 5.6.3, but NuGet reported that Microsoft.Azure.ActiveDirectory.GraphClient require 5.6.4
I tried to use assemblyBinding, but it doesn't work for me (I've tried suggestions from assemblybinding does not work in mstest)
Any suggestions how to make Microsoft.Data.Services.Client loaded?
Can I somehow overwrite nuspec dependencies?
Update: I've created isolated library with single TestMethod, that has the problem.
The FIX: The problem was that in app.config in assemblyBinding/ bindingRedirect I've used File Version instead of Assembly Version, which is different for this assembly (File Version=5.6.4.62175, but Assembly Version=5.6.4.0). Correct configuration is
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
</dependentAssembly>
</assemblyBinding>