ASP.net页面在import语句中获取错误,但我有参考的地方吗?

前端之家收集整理的这篇文章主要介绍了ASP.net页面在import语句中获取错误,但我有参考的地方吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
任何想法为什么我得到下面的错误在我的MVC2项目,即使通过在项目本身我绝对有一个引用“system.Web.Entity”?
  1. Compiler Error Message: CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
  2.  
  3. Source Error:
  4.  
  5. Line 1: <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<List<Node>>" %>
  6. Line 2: <%@ Import Namespace="TopologyDAL" %>
  7. Line 3: <%@ Import Namespace="System.Data.Entity" %>

谢谢

编辑 – 顺便说一句,如果我拿出第3行,那么我得到的错误

  1. Compilation Error
  2. 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.
  3.  
  4. 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'.
  5.  
  6. Source Error:
  7.  
  8. Line 164:
  9. Line 165: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
  10. Line 166: public class views_node_index_aspx : System.Web.Mvc.ViewPage<List<Node>>,System.Web.SessionState.IRequiresSessionState,System.Web.IHttpHandler {
  11. Line 167:
  12. Line 168: private static bool @__initialized;
  13.  
  14.  
  15. 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建议,尝试把它放在你的Web.config文件中:
  1. <compilation debug="true" targetFramework="4.0">
  2. <assemblies>
  3. <add assembly="System.Data.Entity,PublicKeyToken=b77a5c561934e089" />
  4. </assemblies>
  5. </compilation>

猜你在找的asp.Net相关文章