ASP.NET MVC 不明确的类型错误 - “System.Web.Mvc.ViewMasterPage”含糊不清
我创建了一个 ASP.NET MVC 2.0 应用程序。它在第一次测试时运行良好,我对视图做了一些小的编辑。然后我想添加一个新的控制器,所以我必须编译该应用程序。在我运行它之后,我收到以下错误:
Parser Error Message: The type 'System.Web.Mvc.ViewMasterPage' is ambiguous: it could come from assembly 'C:\Users\DerekM\Documents\Visual Studio 2008\Projects\ABELMedicalSoftwareMVC\ABELMedicalSoftwareMVC\bin\System.Web.Mvc.DLL' or from assembly 'C:\Users\DerekM\Documents\Visual Studio 2008\Projects\ABELMedicalSoftwareMVC\ABELMedicalSoftwareMVC\bin\ABELMedicalSoftwareMVC.DLL'. Please specify the assembly explicitly in the type name.
Source Error:
Line 1: <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
Line 2:
Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
我做了一些谷歌搜索并遇到了以下教程: http://blog.stevensanderson.com/2009/02/03/using-the-aspnet-mvc-source-code -to-debug-your-app/
我完全按照它操作,但仍然遇到相同的错误。因此,我现在可以从 bin 文件夹中读取 System.Web.Mvc.dll,并且对 GAC 的引用已从我的 web.config 中删除。
从我从其他帖子中收集到的信息来看,听起来我的视图页面或母版页上的继承是问题所在。但我不知道如何编辑它们。
这是继承自创建的默认 Site.Master MVC
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
这是继承自我的视图
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
论坛帖子,我读到它需要引用后面的代码,但视图中没有后面的代码。它只是一个普通的 Index.aspx 文件。 默认母版页没有隐藏代码,但如果我创建一个新母版页,它会得到 .cs 和 .designer.cs
任何帮助,这似乎是一个简单的问题,我错过了一些非常基本的东西。
I created an ASP.NET MVC 2.0 Application. It ran fine at first test and I made some minor edits to the views. I then wanted to add a new controller so I had to compile the app. After I did anytime I run it I get the following error:
Parser Error Message: The type 'System.Web.Mvc.ViewMasterPage' is ambiguous: it could come from assembly 'C:\Users\DerekM\Documents\Visual Studio 2008\Projects\ABELMedicalSoftwareMVC\ABELMedicalSoftwareMVC\bin\System.Web.Mvc.DLL' or from assembly 'C:\Users\DerekM\Documents\Visual Studio 2008\Projects\ABELMedicalSoftwareMVC\ABELMedicalSoftwareMVC\bin\ABELMedicalSoftwareMVC.DLL'. Please specify the assembly explicitly in the type name.
Source Error:
Line 1: <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
Line 2:
Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
I did some googling and came accross the following tutorial: http://blog.stevensanderson.com/2009/02/03/using-the-aspnet-mvc-source-code-to-debug-your-app/
I followed it exactly but I still get the same error. So I have the System.Web.Mvc.dll reading from my bin folder now, and the reference to the GAC was removed from my web.config.
From what I can gather from other posts it sounds like my inherits on my view pages, or maybe my master pages, is the issue. But I'm not sure how to edit them.
Here is the inherits from the default Site.Master MVC created
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
And here is the inherits from my view
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
Forum posts im reading say it needs to reference the code behind instead, but the views have no code behind in them. It's just a plain Index.aspx file.
The default master page has no code behind, but if I create a new one it gets given a .cs and .designer.cs
Any help appreciated, this seems like such a simple issue and I'm missing something really basic.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你有这个母版页的代码隐藏。
我遇到了同样的问题,这对我有帮助: http ://www.alphapapahotel.com/system-web-mvc-viewmasterpage-parser-erro/aspnet/
I think you have codebehind for this masterpage.
I had the same issue, and this had helped me: http://www.alphapapahotel.com/system-web-mvc-viewmasterpage-parser-erro/aspnet/