'EntityFramework' could not be loaded due to an error.

asp.net-mvc-3 entity-framework


Could not load file or assembly 'EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I only get this error when I add this code into my project:

private IUserRepository repository;

        public SearchController(IUserRepository repo)
            repository = repo;

I suppose that makes sense as I'm using EntityFramework for this. I'm just now sure how to fix this bug.

I've looked at this link: http://msdn.microsoft.com/en-us/library/e74a18c4.aspx Though I'm not sure how to use this program? (It's always blank).

I think that this bug may have something to do with the fact that my database is hosted by dotnet-host.com and that there's some local references that break when it interacts with the database online.

4/3/2012 11:35:50 PM

Accepted Answer

What the error is telling you is that your project referenced a different version of EntityFramework.dll than it found at runtime.

Check which version of EntityFramework.dll did you reference in your project (update your question).

Make sure you copy all the relevant dll and *.manifest into application's bin folder.

Since It's an external host, You might need to install the EntityFramework through WebMatrix Package Manager. If you do, you can follow this tutorial.

  1. Just make sure to install the same version of EntityFramework on your host site that you use for development, or
  2. change your assembly reference to Specific Version = false on EntityFramework dlls (Note I'm not sure if it will work, because I always try to develop and deploy using the same versions, so maybe somebody can confirm?).
4/3/2012 10:39:54 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow