问题描述:

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.

网友答案:

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?).
相关阅读:
Top