Compiler Error Message: CS1061: 'object' does not contain a definition for
'Name' and no extension method 'Name' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Yep, that's a bug we know about. Work around for right now is to make sure the @Page directive is the last pre-processor directive in your file. Will be fixed in Preview 2.
Marked as answer by crowleywilson on Aug 09, 2010 04:30 AM
crowleywilso...
Member
1 Points
1 Post
MVC3: Compilation error on Webforms Views with @Import directive
Aug 06, 2010 04:12 AM|LINK
If I use the webforms view engine with MVC3, using an import directive on a strongly typed view causes a compile time error.
e.g, given the fully qualified model class ImportBug.Models.TestModel,
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TestModel>" %>
<%@ Import namespace="ImportBug.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
...
<h2><%=Model.Name %></h2>
...
Causes the following:
Compiler Error Message: CS1061: 'object' does not contain a definition for 'Name' and no extension method 'Name' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"><%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TestModel>" %></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"><%@ Import namespace="ImportBug.Models" %></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"><asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"></div> <div></div>bradwils
Contributor
5779 Points
691 Posts
Microsoft
Re: MVC3: Compilation error on Webforms Views with @Import directive
Aug 06, 2010 06:45 AM|LINK
Yep, that's a bug we know about. Work around for right now is to make sure the @Page directive is the last pre-processor directive in your file. Will be fixed in Preview 2.