title: RuntimeBinderException with dynamic anonymous objects in MVC
body: <h3>The code</h3>
  
  <p>I've got an MVC project with a partial page that looks somewhat like this:</p>
  
  <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;dynamic&gt;" %&gt;
  &lt;div class="tab-window &lt;%= Model.TargetClass %&gt; &lt;%= Model.TargetTab == Model.SelectedTab ? "selected" : "" %&gt;"
      data-window-url="/SomeUrl/Partial/&lt;%= Model.TargetTab %&gt;/"
      &lt;%= Model.TargetTab == Model.SelectedTab ? "data-content-loaded=\"true\"" : "" %&gt;&gt;
      &lt;% if (Model.TargetTab == Model.SelectedTab) {
             Html.RenderPartial(Model.TargetTab as string, Model.Model as object);
          } %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>What it does is open another partial (the one named in <code>Model.TargetTab</code>) with <code>Model.Model</code> if it's the currently visible tab, otherwise just renders an empty div (which is loaded with jQuery when needed).</p>
  
  <p>It's called like this:</p>
  
  <pre><code>&lt;% Html.RenderPartial("TabWindowContainer", new { TargetTab = "MyTabName", TargetClass = "my-tab-class", SelectedTab = Model.Tab, Model = Model }); %&gt;
  </code></pre>
  
  <p><em>This used to work.</em></p>
  
  <p>Then I changed the value that goes into the <code>Model</code>, and it stopped working. I changed it back, and it's still not working. To be clear, hg status currently doesn't show any of these files.</p>
  
  <h3>The exception</h3>
  
  <pre>Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'object' does not contain a definition for 'TargetClass'</pre>
  
  <p>When you try to open <code>Model</code> in the Quickwatch window you see it has all the properties setup with correct values</p>
  
  <p><img src="https://i.stack.imgur.com/VIAVd.png" alt="Quickwatch"></p>
  
  <p>But when you try to view any property, you get the same exception as before</p>
  
  <p><img src="https://i.stack.imgur.com/CqIKU.png" alt="Quickwatch with exception"></p>
  
  <p><strike>Thinking about it, I realized that possibly, this shouldn't work at all; the object we're trying to access is from a different assembly so we wouldn't see its properties. But then, why did it use to work? I still have a running version where this works. What can I do to make it work again?</strike></p>
  
  <p>Update: It <em>should</em> work; the model is coming from another view in the same assembly, not from the controller.</p>