ASP.NET MVC 不明确的类型错误 - “System.Web.Mvc.ViewMasterPage”含糊不清

发布于 2024-08-29 17:24:41 字数 1666 浏览 2 评论 0原文

我创建了一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天 2024-09-05 17:24:41

我认为你有这个母版页的代码隐藏。

更改继承自
改为 System.Web.Mvc.ViewMasterPage
System.Web.UI.MasterPage。

我遇到了同样的问题,这对我有帮助: http ://www.alphapapahotel.com/system-web-mvc-viewmasterpage-parser-erro/aspnet/

I think you have codebehind for this masterpage.

Change the inherit from
System.Web.Mvc.ViewMasterPage instead
of System.Web.UI.MasterPage.

I had the same issue, and this had helped me: http://www.alphapapahotel.com/system-web-mvc-viewmasterpage-parser-erro/aspnet/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文