Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC strongly typed view compilation error
    text
    copied!<p>This is a strange one. I changed something (not sure what) and now my app's view doesn't compile at runtime.</p> <p>The view itself is strongly typed:</p> <pre><code>&lt;%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;MyNamespace.OperatorModel&gt;" %&gt; </code></pre> <p>When I visit the page, it fails to compile, saying:</p> <blockquote> <p>CS1061: 'object' does not contain a definition for 'Log' and no extension method 'Log' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)</p> </blockquote> <p>Pretty standard error. The corresponding source code line is:</p> <pre><code>&lt;%= Html.HiddenFor(model =&gt; model.Log) %&gt; </code></pre> <p>When I look at the compiler-generated code, I see that the base class of the view is not strongly typed:</p> <pre><code>[System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()] public class views_operator_create_aspx : global::System.Web.Mvc.ViewPage, // NOT STRONGLY TYPED System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler { </code></pre> <p>So my question is, what is causing the view compiler to ignore my <code>Inherits</code> attribute on the view definition?</p> <p>I should point out that other views on the same controller are working, and they have exactly the same page declaration as I've shown above.</p> <p><strong>EDIT</strong> Does anyone know where the generated source code file lives, assuming it is persisted somewhere?</p> <p><strong>EDIT</strong> I found the culprit (in my answer below) but I've no idea why this is happening. If someone can explain I'd appreciate it!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload