我有一个包含三个项目的解决方案。
- DomainModel(带有 ADO.NET Entity Framework 的 C# 库)
- DomainModelTest(业务逻辑单元测试)
- Web 应用程序(使用 DomainModel)
出于某种原因,如果我传递 DomainModel 中的任何对象,我什至无法带来 View ,甚至不是简单的对象。我收到以下错误:
有什么想法吗?
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=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Source Error:
Line 146: Line 147:
[System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()] Line 148: public class views_home_index_aspx : System.Web.Mvc.ViewPage, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler { Line 149:
Line 150: private static bool @__initialized;
我认为这可能会有所帮助,实际错误出现在 Default.aspx 文件中的以下行中:
public partial class _Default : Page
{
public void Page_Load(object sender, System.EventArgs e)
{
// Change the current path so that the Routing handler can correctly interpret
// the request, then restore the original path so that the OutputCache module
// can correctly process the response (if caching is enabled).
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current); //**HERE**
HttpContext.Current.RewritePath(originalPath, false);
}
}
最佳答案
尝试在 web.config 的 < assembly > 部分中添加引用。
关于c# - ADO.NET Entity Framework 和 ASP.MVC 的组合有没有错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1501616/