Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET MVC Ambiguous Type Reference

Tags:

asp.net-mvc

Not entirely sure what's going on here; any help would be appreciated.

I'm trying to create a new .NET MVC web app. I was pretty sure I had it set up correctly, but I'm getting the following error:

The type 'System.Web.Mvc.ViewPage' is ambiguous: it could come from assembly 
'C:\MyProject\bin\System.Web.Mvc.DLL' or from assembly 
'C:\MyProject\bin\MyProject.DLL'. Please specify the assembly explicitly in the type name.

The source error it reports is as follows:

Line 1:  <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
Line 2:  
Line 3:  <asp:Content ID="indexContent" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">

Anything stand out that I'm doing completely wrong?

like image 856
Jordan H. Avatar asked Dec 17 '22 10:12

Jordan H.


1 Answers

I suppose you named one of your page "ViewPage" is that the case?

And like @Jonathan mentioned, this smells:

Inherits="System.Web.Mvc.ViewPage"

On my MVC application, all the view pages have this instead:

Inherits="MySite.Views.Pages.Home"

Or something along the line. Your aspx page markup should have "Inherits" point to your code-behind class name, not the actual class that it is inheriting. The attribute name is rather misleading but its an artifact of earlier days.

like image 163
chakrit Avatar answered Jan 12 '23 02:01

chakrit