Could not load file or assembly 'Microsoft.Data.Edm'

37

We are using the Windows Azure Storage NuGet package version 4.1.0, this has a dependency on Microsoft.Data.OData and has added that package as well which has the Microsoft.Data.Edm dll. When we build and run the application we very occasionally get the following error:

Could not load file or assembly 'Microsoft.Data.Edm' or one of its dependencies. The
located assembly's manifest definition does not match the assembly reference. (Exception
from HRESULT: 0x80131040)

We have the following binding redirect in the web.config and also have checked and this is the only version of Microsoft.Data.Edm being referenced by any projects in the solution.

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.6.1.0" newVersion="5.6.1.0" />
  </dependentAssembly>

Sometimes when I look in the bin folder I find the dll version of Microsoft.Data.Edm is v 5.6.0. I have been through all the projects and I cannot find a reference to Microsoft.Data.Edm except with the storage client and that is definitely 5.6.1.

What is the best way to try and work out where the 5.6.0 version is coming from? When we do get this error we delete the bin and obj folders and rebuild and then it works fine, the 5.6.1 version is there and everything works but eventually it happens again.

EDIT:

We have upgraded again to all the latest versions from NuGet and still no luck, I ran a tool which shows the following dependencies:

Possible conflicts for Microsoft.Data.Edm:

Microsoft.Data.OData      references Microsoft.Data.Edm, Version=5.6.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.Data.Services.Client references Microsoft.Data.Edm, Version=5.6.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.WindowsAzure.Storage references Microsoft.Data.Edm, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Possible conflicts for Microsoft.Data.OData:

Microsoft.Data.Services.Client references Microsoft.Data.OData, Version=5.6.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.WindowsAzure.Storage references Microsoft.Data.OData, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

What I don't understand is we have the app binding redirects set but sometime the 2.6.0 version is copied in and sometimes the 2.6.2. Does anyone know why this would be happening, never had this problem before.

c#
.net
azure
dll
asked on Stack Overflow Aug 7, 2014 by user351711 • edited Jul 24, 2017 by SteveC

11 Answers

20

I had the same error message but my issue was unrelated to any Azure product. In my case, I updated OData from version 3 to 4 and it appears to me that Nuget left behind binding redirects for deprecated dll's. There were actually three in total, Microsoft.Data.Edm, Microsoft.Data.OData and System.Spatial.

My solution was to remove the deprecated binding redirects. You should also remove the old dll's sitting in your bin folder if your build process doesn't.

answered on Stack Overflow Apr 6, 2015 by Bill
4

One thing that sometimes seems to resolve this issue for members of my team is to close all instances of Visual Studio, delete the contents of the packages directory, re-open Visual Studio, and then restore packages and rebuild. This doesn't always work though.

We were able to trace the issue on one of our machines by identifying the problematic project by increasing the Visual Studio build output verbosity:

Increasing Visual Studio build output verbosity

Then, we searched the output and identified the target project that was problematic by searching for "Microsoft.Data.Edm". We noticed that it seemed to have an indirect dependency to Microsoft.Data.Edm, but we noticed that the assembly was not explicitly included as a package for that project. So, using the Nuget package console, we targeted the project and ran: Install-Package Microsoft.Data.Edm which resolved the issue.

Install Package with Nuget

answered on Stack Overflow Aug 16, 2016 by devinbost • edited Aug 16, 2016 by devinbost
3

Here's few things you can try:

  1. Check your Post Build event to make sure no Microsoft.Data.Edm.dll file is being copied manually to bin folder.
  2. Make sure other packages don't have dependency to Microsoft.Data.Edm 5.6.1. Easy way to do this is by looking at your package.config files.
  3. If your code is in source control, make sure nobody check in bin folder. I am surprised by how many people don't know this basic rule.
  4. Uninstall WindowsAzure.Storage and Microsoft.Data.Edm packages. Then install again and make sure you only install the stable version.

HTH.

answered on Stack Overflow Nov 20, 2014 by stack247
2

I met a similar case today, in my situation, the build always copy a old version dll to debug folder, the reason is my project isn't reference this dll directly, it ref another project which refering this dll.
So when build, my project find a old version from GAC or other place.
I solved it by explicit reference this dll in project from the right location.
like this:

<Reference Include="Microsoft.Data.Services.Client, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\packages\Microsoft.Data.Services.Client.5.6.1\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
</Reference>
answered on Stack Overflow Apr 9, 2015 by dasons
2

I've just had this same issue on my build server and on checking the build output I noticed the following:

Copying file from "C:\Program Files (x86)\Microsoft WCF Data Services\5.6\bin.NETFramework\Microsoft.Data.Edm.dll" to "bin\Microsoft.Data.Edm.dll".

Seems that there is something installed on the build server that is not on my machine, so I need to track that down.

answered on Stack Overflow Sep 15, 2015 by Carl
1

It's probably may be problem of virtual path on IIS (I think, this assembly loaded first on application start).

I got same problem when start two project from different locations on disk but with same virtual paths.

Resolution is delete this path from IIS, reset IIS process and create virtual path again from VS.

answered on Stack Overflow Oct 28, 2015 by holder
1

found it !!
inside your app.config file change the bindingredirect version.
Make bindingredirect element refer to the version the exception complains about, and the exception will go away.
explanation:
Probably the app.config file and the project reference assembly got out of sync, causing the error.

<runtime>
		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
			<dependentAssembly>
				<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
				<bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" />
			</dependentAssembly>
		</assemblyBinding>
	</runtime>

answered on Stack Overflow Mar 28, 2018 by hannes neukermans
0

For me I had to uninstall WindowsAzure.MobileServices.Backend.Entity NuGet package which removes a lot of assemblies, including Microsoft.Data.Edm. And then I just re-installed it and miraculously, it worked!

This was in my Azure Mobile Services WebApi project, so it needed to work, and thankfully it does now.

I hope this helps.

answered on Stack Overflow Feb 19, 2015 by King Wilder
0

This was successfully solved for me by closing and re-opening Visual Studio.

answered on Stack Overflow Dec 11, 2017 by BCarpe
0

1) Turn Build Verbosity to Detailed 2) Search for Microsoft.Data.Edm and compare the versions of other assemblies used in the project 3) Update to the Version used in other assemblies

Solved my problem

answered on Stack Overflow Apr 30, 2019 by Michael Staples
0

I got this error after I had deleted my "packages" folder and re-installed the packages. I was being able to resolve the error by running "Clean Solution" and "Rebuild Solution".

answered on Stack Overflow Jul 9, 2019 by Brent Keller

User contributions licensed under CC BY-SA 3.0