你知道为什么在我的MVC2项目中会出现下面的错误吗?即使在项目本身中,我肯定引用了"system.Web.Entity"?

Compiler Error Message: CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

Source Error:

Line 1:  <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<List<Node>>" %>
Line 2:  <%@ Import Namespace="TopologyDAL" %>
Line 3:  <%@ Import Namespace="System.Data.Entity" %>

谢谢

编辑-顺便说一句,如果我删除第3行,则会得到错误:

 Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Source Error:

Line 164:    
Line 165:    [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
Line 166:    public class views_node_index_aspx : System.Web.Mvc.ViewPage<List<Node>>, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler {
Line 167:        
Line 168:        private static bool @__initialized;


Source File: c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\6ec16fd2\a2147d7c\App_Web_index.aspx.1b64bdf1.ajruf7pv.0.cs    Line: 166 

推荐答案

按照miensol的建议,try 将其放入Web.config文件:

<compilation debug="true" targetFramework="4.0">
  <assemblies>
    <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </assemblies>
</compilation>

Asp.net相关问答推荐

ASP.NET MVC项目中的产品采购并发性测试

如何在 asp.net 服务器中使用字体

内容根路径在 .NET 6 中如何工作?

.net 中的 [] 括号是什么?

无法加载文件或程序集.无效指针(HRESULT 异常:0x80004003 (E_POINTER))

asp.net 单选按钮分组

MSCharts找不到请求类型'GET'的http处理程序错误

System.Net.Http 版本冲突导致构建警告

可空日期时间转换

LINQ:使用 Lambda 表达式获取 CheckBoxList 的所有选定值

使 Web.config 转换在本地工作

IIS Express 安装目录在哪里?

由于文件路径太长,网站发布失败

导航到本地 IIS Express 时,Chrome 会返回错误请求 - 请求太长

System.Reflection.Assembly.LoadFile 锁定文件

使用 ASP.NET 进行重定向后获取

Ashx 文件中的 HttpContext.Current.Session 为空

通过 CultureInfo 格式化字符串

强制 IIS Express 进入classic 管道模式

ConfigurationManager.AppSettings 缓存