无法加载文件或程序集EntityFramework [英] Could not load file or assembly EntityFramework

查看:303
本文介绍了无法加载文件或程序集EntityFramework的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经部署了ASP.NET MVC 4应用程序,并且主页可以正常加载,但是当我尝试访问任何其他页面(所有这些都尝试连接到SQL数据库)时,出现此错误:

I've deployed an ASP.NET MVC 4 application and the home page loads fine, but when I try to access any other page (which all try to connect to a SQL database) I get this error:

无法加载文件或程序集'EntityFramework,Version = 4.1.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配. (来自HRESULT的异常:0x80131040) 说明:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息.

Could not load file or assembly 'EntityFramework, Version=4.1.0.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) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

异常详细信息:System.IO.FileLoadException:无法加载文件或程序集"EntityFramework,Version = 4.1.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089"或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配. (来自HRESULT的异常:0x80131040)

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'EntityFramework, Version=4.1.0.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)

我已经检查了Web.config文件,它具有以下相关条目:

I've checked the Web.config file and it has the following relevant entries:

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
...
<compilation targetFramework="4.0" />

我已经阅读了所有可以通过Google找到的内容,但到目前为止没有任何帮助.我知道我用来构建应用程序的EF版本与部署计算机上的版本有所不同,但是我可以使用一些方向来纠正这种差异.

I've read everything I could find via Google but nothing as helped so far. I know that somehow the version of EF I built the application with is different than the version that's on the deployment machine but I could use some direction in how to correct this difference.

推荐答案

您似乎在.NET Framework 4上使用EF5(因此配置文件中的版本为4.4.0.0),但是您遇到的例外是谈论EF 4.1 (版本为4.1.0.0).似乎您正在使用的某些程序集仍尝试使用4.1,而其他EF5(4.4.0.0).确保在任何地方都引用相同的程序集.因此,您需要更新所有引用以使用EF5并重建项目. 顺便提一句.配置文件中的条目只是将.NET Framework指向知道如何读取config部分的Type,因此不足以对其进行更新以使应用程序针对EF5

You seem to be using EF5 on .NET Framework 4 (hence the version 4.4.0.0 in your config file) but the exception you get is talking about EF 4.1 (the version is 4.1.0.0). It seems like some assemblies you are using still try to use 4.1 while the other EF5 (4.4.0.0). Make sure you reference the same assembly everywhere. So, you need to update all the references to use EF5 and rebuild the project. Btw. the entry in the config file is just to point the .NET Framework to a Type that knows how to read the config section so it is not enough to update this to make the app work against EF5

这篇关于无法加载文件或程序集EntityFramework的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆