Reputation: 3528
I'm totally flabbergasted by this.
I have a Asp.Net MVC v 5.2.3 project.
When i include https://github.com/NicoJuicy/ngravatar ( not published on the default nuget repo yet).
The NGravatar nuget package sample works on Mvc v. 5.2.3.
When i include it in my own project, OData dll gives me an error:
System.IO.FileLoadException: 'Could not load file or assembly 'Microsoft.OData.Core, Version=7.6.1.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)'
When i remove the NGravatar package. The error is gone.
The odata version used in the project is v. 5.18 . So i don't want v 7.6.1.0 that is suggested by the runtime error.
In short, when NGravatar is not used. OData uses the correct version. When NGravatar is included, the package version magically updates.
What could be the cause of this?
Upvotes: 0
Views: 238
Reputation: 23715
In short, when NGravatar is not used. OData uses the correct version. When NGravatar is included, the package version magically updates.
I think the main issue is related to your own project itself or VS Invironment.
Check for both nuget package Microsoft.OData.Core and NGravatar, I found that there is no dependency between them, just two separate, non-interfering packages. And in my side, I test it and face no such issue as you described.
So I wonder the other nuget package dependencies in your current project are out of order or the redirection relationship is out of order, or a problem in the global package cache address that affects the project, etc. Since I did not have your project sample or VS Invironment, So please check in your side carefully.
You could try these suggestions to troubleshoot your issue:
1) clean all nuget caches or delete all files under C:\Users\xxx(current user)\.nuget\packages
2) close VS Instance, delete .vs
hidden folder under folder , bin
and obj
folder.
3) disable any third party extensions under Extensions-->Manage Extensions in case they cause this abnormal behavior.
4) Run update-package -reinstall
under Tools
-->NuGet Packager Manager
-->Package Manager Console
to re-establish the relationship.
After that run Get-Project -All | Add-BindingRedirect
to reinstall the rebinding.
Then please add these node in Web.config
file to rebind the Microsoft.Odata.core
assembly to be identified by the project
<dependentAssembly>
<assemblyIdentity name="Microsoft.OData.Core" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-6.19.0.11114" newVersion="6.18.0.10905" />
</dependentAssembly>
Hope it could help you.
Upvotes: 1
Reputation: 3528
I ran AsmSpy on my binaries, which gave this:
Reference: Microsoft.OData.Core
Microsoft.OData.Core, Version=6.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Source: NotFound
6.10.0.0 by System.Web.OData, Version=5.5.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.OData.Core, Version=6.19.0.11114, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Source: Local, Location: C:\source\Shop\src\Presentation\Legacy\Shop.Front\bin\Microsoft.OData.Core.dll
Microsoft.OData.Core, Version=7.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Source: NotFound
7.6.1.0 by Microsoft.AspNet.OData, Version=7.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
So i noticed that the redirect was not correctly happening. So according to the information i had from AsmSpy and the dll version in the bin directory ( v. 6.15.0.0) , i added this:
<dependentAssembly>
<assemblyIdentity name="Microsoft.OData.Core" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-6.19.0.11114" newVersion="6.15.0.0" />
</dependentAssembly>
With this method recursively, i continued updating till Microsoft.AspNet.OData
I have no idea why NGravatar triggered this though.
Upvotes: 1