title: "Cannot create an instance of an Interface" (an MvC 3 Wizard inside Orchard CMS)
body: <p>Based on the great answer at <a href="https://stackoverflow.com/questions/6402628/multi-step-registration-process-issues-in-asp-net-mvc-splitted-viewmodels-sing?answertab=votes#tab-top">multi-step registration process issues in asp.net mvc (splitted viewmodels, single model)</a>, I used the example Darin Dimitrov provided to test out an ASP.net MVC3 wizard. It works standalone, but not inside Orchard CMS v1.3.</p>
  
  <p>I am getting the following error:</p>
  
  <hr>
  
  <blockquote>
    <p>Server Error in '/' Application.</p>
    
    <p>Cannot create an instance of an interface.</p>
    
    <p>Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code. </p>
    
    <p>Exception Details: System.MissingMethodException: Cannot create an
    instance of an interface.</p>
    
    <p>Source Error: </p>
    
    <p>An unhandled exception was generated during the execution of the
    current web request. Information regarding the origin and location of
    the exception can be identified using the exception stack trace below.</p>
    
    <p>Stack Trace: </p>
    
    <p>[MissingMethodException: Cannot create an instance of an interface.]<br>
    System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean
    publicOnly, Boolean noCheck, Boolean&amp; canBeCached,
    RuntimeMethodHandleInternal&amp; ctor, Boolean&amp; bNeedSecurityCheck) +0<br>
    System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
    skipCheckThis, Boolean fillCache) +98<br>
    System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly,
    Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean
    fillCache) +241    System.Activator.CreateInstance(Type type, Boolean
    nonPublic) +69<br>
    System.Web.Mvc.DefaultModelBinder.CreateModel(ControllerContext
    controllerContext, ModelBindingContext bindingContext, Type modelType)
    +199    System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext
    controllerContext, ModelBindingContext bindingContext) +572<br>
    System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext
    controllerContext, ModelBindingContext bindingContext) +449<br>
    System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext
    controllerContext, ParameterDescriptor parameterDescriptor) +317<br>
    System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext
    controllerContext, ActionDescriptor actionDescriptor) +117<br>
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
    controllerContext, String actionName) +343<br>
    System.Web.Mvc.Controller.ExecuteCore() +116<br>
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
    +97    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext
    requestContext) +10<br>
    System.Web.Mvc.&lt;>c__DisplayClassb.b__5() +37<br>
    System.Web.Mvc.Async.&lt;>c__DisplayClass1.b__0() +21<br>
    System.Web.Mvc.Async.&lt;>c__DisplayClass8<code>1.&lt;BeginSynchronous&gt;b__7(IAsyncResult
    _) +12    System.Web.Mvc.Async.WrappedAsyncResult</code>1.End() +62    System.Web.Mvc.&lt;>c__DisplayClasse.b__d() +50<br>
    System.Web.Mvc.SecurityUtil.b__0(Action f) +7 
    System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
    +22    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60<br>
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
    result) +9<br>
    Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult
    result) in
    d:\Builds\OrchardFull\src\Orchard\Mvc\Routes\ShellRoute.cs:148<br>
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    +8963149    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +184</p>
    
    <p>Version Information: Microsoft .NET Framework Version:4.0.30319;
    ASP.NET Version:4.0.30319.237</p>
  </blockquote>
  
  <hr>
  
  <p>I am venturing a guess that it's the controller that's causing a fuss.  Here is the code:</p>
  
  <pre><code>[Themed]
      public class WizardController : Controller
      {
          public ActionResult Index()
          {
              var wizard = new WizardViewModel();
              wizard.Initialize();
              return View(wizard);
          }
  
          [HttpPost]
          public ActionResult Index([Deserialize] WizardViewModel wizard, IStepViewModel step)
          {
              wizard.Steps[wizard.CurrentStepIndex] = step;
              if (ModelState.IsValid)
              {
                  if (!string.IsNullOrEmpty(Request["next"]))
                  {
                      wizard.CurrentStepIndex++;
                  }
                  else if (!string.IsNullOrEmpty(Request["prev"]))
                  {
                      wizard.CurrentStepIndex--;
                  }
                  else
                  {
                      // TODO: we have finished: all the step partial
                      // view models have passed validation =&gt; map them
                      // back to the domain model and do some processing with
                      // the results
  
                      return Content("thanks for filling this form", "text/plain");
                  }
              }
              else if (!string.IsNullOrEmpty(Request["prev"]))
              {
                  // Even if validation failed we allow the user to
                  // navigate to previous steps
                  wizard.CurrentStepIndex--;
              }
              return View(wizard);
          }
      }
  </code></pre>
  
  <p>But I am not 100% sure, and the other culprit could be the WizardViewModel:</p>
  
  <pre><code>[Serializable]
  public class WizardViewModel
  {
      public int CurrentStepIndex { get; set; }
      public IList&lt;IStepViewModel&gt; Steps { get; set; }
  
      public void Initialize()
      {
          Steps = new IStepViewModel[]
          {
              new Step1ViewModel(),
              new Step2ViewModel(),
              new Step3ViewModel()
          };
      }
  }
  </code></pre>
  
  <p>That last part is a manual insertion of the steps and alters the code originally posted (direct from author).  Any help is greatly appreciated.</p>