ASP.NET MVC模糊类型错误 - 'System.Web.Mvc.ViewMasterPage'不明确

时间:2010-04-20 13:54:29

标签: asp.net-mvc master-pages

我创建了一个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,并且从我的web.config中删除了对GAC的引用。

从我可以从其他帖子收集到的内容,听起来我在我的视图页面上继承,或者可能是我的母版页,这是问题。但我不确定如何编辑它们。

这是从默认的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

任何帮助表示赞赏,这似乎是一个简单的问题,而且我遗漏了一些非常基本的东西。

1 个答案:

答案 0 :(得分:1)

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

  

更改继承   而是System.Web.Mvc.ViewMasterPage   System.Web.UI.MasterPage。

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

相关问题