你知道为什么在我的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相关问答推荐

Windows 命令行中的/p:是什么意思

如何注册路由区域

在 ASP.Net 中使用 Page_Load 和 Page_PreRender

HttpResponse 的区别:SetCookie、AppendCookie、Cookies.Add

下载功能在 asp.net 的更新面板中不起作用

asp.net mvc 中的 RedirectToAction 用法

将 ListItem 的 ASP.NET 列表数据绑定到 DropDownList 问题

ASP.NET Core 中的授权. [Authorize] 属性总是 401 Unauthorized

asp.net Button OnClick 事件未触发

如何确定服务器端 C# 上的浏览​​器窗口大小

asp.net 有控制台日志(log)吗?

ASP .NET Button 事件处理程序不会在第一次单击时触发,而是在 PostBack 后的第二次单击时触发

将当前谷歌 map 保存为图片

模型是否包含字段而不将其添加到数据库中?

ASP.NET 发布try 复制不存在的文件

如何遍历自定义 vb.net 对象的每个属性?

ASP.NET MVC 和 httpRuntime executionTimeout

ASP.NET - 从静态方法/静态类访问会话?

ModelClientValidationRule 冲突

禁用文本框的模型绑定