Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly 'EntityFramework' error

Could not load file or assembly 'EntityFramework, Version=4.3.1.0, 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.

like image 419
Hanna Avatar asked Apr 03 '12 22:04

Hanna


People also ask

Could not load file or assembly EntityFramework dll?

'EntityFramework' could not be loaded due to an error. 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). ...

How do I reference EntityFramework DLL?

Go to references --> Add Reference --> in the dialog, choose COM and press browse. Then go to your project which is using EF and go to the projects bin folder where the EF references are stored. Select the EntityFramework.


1 Answers

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?).
like image 138
surfen Avatar answered Oct 08 '22 20:10

surfen