title: How can I get ReSharper to correctly find an MVC3 section in an alternate layout?
body: <p>R# is incorrectly reporting one of my MVC3 views as having an error. I have 2 layouts, each with different sections defined:</p>
  
  <pre><code>@{
      Layout = "~/Views/Shared/layout2.cshtml";
  }
  @section Layout2Section { @* Layout2Section is red, reported as error by R#. *@
      &lt;span&gt;Injected into LayoutSection2&lt;/span&gt;
  }
  </code></pre>
  
  <p>The view displays fine in a browser. Here is code from layout2:</p>
  
  <pre><code>@RenderSection("Layout2Section", false)
  @if (!IsSectionDefined("Layout2Section"))
  {
      &lt;span&gt;default layout2 section&lt;/span&gt;
  }
  </code></pre>
  
  <p>There is another layout view in <code>~/Views/Shared</code> named <code>_Layout.cshtml</code>, the default in an MVC3 project. R# is only giving intellisense for sections in <code>_Layout.cshtml</code>, not <code>layout2.cshtml</code>. I have tried prefixing with an underscore, it does not work. If I try to define any section in <code>layout2.cshtml</code> that is not defined in <code>_Layout.cshtml</code>, R# is calling it an error. How to disable this, either to tell R# that the view is a section definer, or to get rid of the "1 file with errors" message?</p>
  
  <p><strong>Update</strong></p>
  
  <p>After derigel's comment, I realized that the above code is not exactly what I have in my project. Specifically, the line that defines the layout uses T4MVC like so:</p>
  
  <pre><code>@{
      Layout = MVC.Shared.Views.layout;
  }
  </code></pre>
  
  <p>If I change it to a string as in the original question, the R# error goes away. @Derigel, shall I still create a test project and post to your tracker? I just reproduced the above update in a brand new MVC3 project, after adding the T4MVC lib. </p>