Cannot create an instance of an interface

rspaulino picture rspaulino · Dec 13, 2011 · Viewed 15.9k times · Source

after install profile 1.1, add at least one field to the User Content Types then go to the Users module and click on Add a new user, click save and you should get this error. any help would be appreciate.

Server Error in '/OrchardLocal' Application.

Cannot create an instance of an interface. 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.

Exception Details: System.MissingMethodException: Cannot create an instance of an interface.

Source Error: 


Line 146: public void EndProcessRequest(IAsyncResult result) {
Line 147: try {
Line 148: _httpAsyncHandler.EndProcessRequest(result);
Line 149: }
Line 150: finally {


Source File: C:\Users\rspaulino\Desktop\src\Orchard\Mvc\Routes\ShellRoute.cs Line: 148 

Stack Trace: 


    [MissingMethodException: Cannot create an instance of an interface.]
    System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
    System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
    System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
    System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
    System.Web.Mvc.DefaultModelBinder.CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) +199
    System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +572
    System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +449
    System.Web.Mvc.DefaultModelBinder.GetPropertyValue(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, IModelBinder propertyBinder) +17
    System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) +399
    System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) +93
    System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) +53
    System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +1367
    System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +449
    System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +317
    System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +117
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
    System.Web.Mvc.Controller.ExecuteCore() +116
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
    System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
    System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
    System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
    System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
    System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
    System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
    Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in C:\Users\rspaulino\Desktop\src\Orchard\Mvc\Routes\ShellRoute.cs:148
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8963149
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +

184


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237

Answer

Piotr Szmyd picture Piotr Szmyd · Dec 21, 2011

Wow, ran into exactly the same error today (but not sure if that was the same module)!

It's a bug in one of the view models. Someone had put an interface there instead of class one (eg. IUser instead of UserPartRecord). Model binder shouts because it cannot create an instance of an object to bind form parameter(s) to.

Your only option is to change the type of that parameter (which one - you have to find out) to a concrete type. The quickest way would be to create a simple class implementing that interface and replace the parameter type with it.

EDIT: A similar problem was discussed (and solved) here and here.