title: Extension methods cannot be dynamically dispatched error - how do I solve this?
body: <p>Can't find the proper solution to this problem.</p>
  
  <p>I am using <code>[Serializable]</code> (MVC3 Futures) in order to have a "wizard" with separate views. Here is the code in my controller to serialize:</p>
  
  <pre><code> private MyViewModel myData;
          protected override void OnActionExecuting(ActionExecutingContext filterContext)
          {
              var serialized = Request.Form["myData"];
              if (serialized != null) //Form was posted containing serialized data
              {
                  myData = (MyViewModel)new MvcSerializer().Deserialize(serialized, SerializationMode.Signed);
                  TryUpdateModel(myData);
              }
              else
                  myData = (MyViewModel)TempData["myData"] ?? new MyViewModel();
              TempData.Keep();
          }
          protected override void OnResultExecuted(ResultExecutedContext filterContext)
          {
              if (filterContext.Result is RedirectToRouteResult)
                  TempData["myData"] = myData;
          }
  </code></pre>
  
  <p>Further along in my controller I do something like this (just a snippet - code goes through wizard with next and back button strings):</p>
  
  <pre><code>public ActionResult Confirm(string backButton, string nextButton)
          {
              if (backButton != null)
                  return RedirectToAction("Details");
  
              else if ((nextButton != null) &amp;&amp; ModelState.IsValid)
                  return RedirectToAction("Submitted");
              else
                  return View(myData);
          }
  </code></pre>
  
  <p>In my <code>.cshtml</code> view, I have this:</p>
  
  <pre><code>@using (Html.BeginFormAntiForgeryPost())
      { 
           @Html.Hidden("myData", new MvcSerializer().Serialize(Model, SerializationMode.Signed))
      ...
           @Html.TextBoxFor(m =&gt; model.Step.EMail)
      ...
      }
  </code></pre>
  
  <p>Because I am using dynamics, I have to use a variable instead in the view:</p>
  
  <pre><code>var model = (MyViewModel) Model.myData;
  </code></pre>
  
  <p>in order to do the <code>@Html.TextBoxFor</code> above. And herein lies my probelm, because if I do <code>@model MyViewModel</code> instead, then I can't do <code>model.Step.EMail</code>. But because of dynamics, the <code>@Html.Hidden</code> won't work and I get the following error:</p>
  
  <blockquote>
    <p>Compiler Error Message: CS1973: 'System.Web.Mvc.HtmlHelper'
    has no applicable method named 'Hidden' but appears to have an
    extension method by that name. Extension methods cannot be dynamically
    dispatched. Consider casting the dynamic arguments or calling the
    extension method without the extension method syntax.</p>
  </blockquote>
  
  <p>I can switch to some other way of doing this without <code>[Serializable]</code>, but then I have to convert a LOT of code. Is there any way to make this work?</p>