【问题标题】:ASP.NET MVC Ambiguous type error - 'System.Web.Mvc.ViewMasterPage' is ambiguousASP.NET MVC 不明确的类型错误 - 'System.Web.Mvc.ViewMasterPage' 不明确
【发布时间】:2014-05-18 17:19:47
【问题描述】:

我创建了一个 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

感谢任何帮助,这似乎是一个简单的问题,我错过了一些非常基本的东西。

【问题讨论】:

    标签: asp.net-mvc master-pages


    【解决方案1】:

    我认为您有此母版页的代码隐藏。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-21
      • 2016-04-06
      • 2011-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多