Search code examples
c#.netazuremef

MEF composition failing to find System.Data.Edm 5.6


I'm trying to compose my app but MEF keeps spitting me the error:

Could not load file or assembly 'Microsoft.Data.Edm, Version=5.6.0.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)

And now i'm stucked... i've tried to replicate the problem in a small scale kind of project, but i can't! which means im doing something wrong here... i need help... i'm quite lost and frustrated and i dont know what kind of info you would need in advance... so, ask for whatever you need!

The basic architecture is:

  • 4 projects, being one WebApi (where i`m composing), one library (where all interfaces are located), one Domain and one DataAccessLayer...
  • WebApi, Domain and DataAccessLayer projects reference the "Library" (they don't reference each other... very loosely coupled I think)
  • DataAccessLayer has Azure.Storage NuGet package installed because it handles data in azure (cache and storage)... I also installed it on WebApi because i was unable to "move" the required dlls efficiently. (at run time all dlls, including Data.EDM, are in the bin folder, i've checked)

If any extra info is necessary pls ask!


Solution

  • Those MEF errors can be tricky... usually it's very subtle stuff that trips it up. Try the following:

    • Check if the projects have the CopyLocal value to True
    • Check if the NuGet Packages all have the same version.