Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 无法创建接口的实例_Asp.net_Asp.net Mvc_Asp.net Mvc 3_Model Binding_Orchardcms - Fatal编程技术网

Asp.net 无法创建接口的实例

Asp.net 无法创建接口的实例,asp.net,asp.net-mvc,asp.net-mvc-3,model-binding,orchardcms,Asp.net,Asp.net Mvc,Asp.net Mvc 3,Model Binding,Orchardcms,安装概要文件1.1后,向用户内容类型至少添加一个字段,然后转到用户模块,单击添加新用户,单击保存,您应该会收到此错误。任何帮助都将不胜感激 “/OrchardLocal”应用程序中出现服务器错误。 无法创建接口的实例。 描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源 Exception Details: System.MissingMethodException: Cannot create an instance of an inte

安装概要文件1.1后,向用户内容类型至少添加一个字段,然后转到用户模块,单击添加新用户,单击保存,您应该会收到此错误。任何帮助都将不胜感激

“/OrchardLocal”应用程序中出现服务器错误。 无法创建接口的实例。 描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源

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) +
异常详细信息:System.MissingMethodException:无法创建接口实例。
源错误:
第146行:公共无效EndProcessRequest(IAsyncResult结果){
第147行:试试看{
第148行:_httpasynchHandler.EndProcessRequest(结果);
第149行:}
第150行:最后{
源文件:C:\Users\rspaulino\Desktop\src\Orchard\Mvc\Routes\ShellRoute.cs行:148
堆栈跟踪:
[MissingMethodException:无法创建接口的实例。]
System.RuntimeTypeHandle.CreateInstance(RuntimeType类型、Boolean publicOnly、Boolean noCheck、Boolean&canBeCached、RuntimeMethodHandleInternal&ctor、Boolean&bNeedSecurityCheck)+0
System.RuntimeType.CreateInstanceSlow(布尔publicOnly、布尔skipCheckThis、布尔fillCache)+98
System.RuntimeType.CreateInstanceDefaultCtor(布尔publicOnly、布尔skipVisibilityChecks、布尔skipCheckThis、布尔fillCache)+241
System.Activator.CreateInstance(类型,布尔非公共)+69
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.BindCompleteXelementalModel(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__显示类b.b__5()+37
System.Web.Mvc.Async.c__显示类1.b__0()+21
System.Web.Mvc.Async.c_uuudisplayClass8`1.b_uuu7(IAsyncResult)+12
System.Web.Mvc.Async.WrappedAsyncResult`1.End()+62
System.Web.Mvc.c_uuudisplayClasse.b_uuud()+50
System.Web.Mvc.SecurityUtil.b___0(操作f)+7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(操作)+22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)+60
System.Web.Mvc.MvcHandler.System.Web.IHTTPassynchandler.EndProcessRequest(IAsyncResult结果)+9
C:\Users\rspaulino\Desktop\src\Orchard\Mvc\Routes\ShellRoute.cs:148中的Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult结果)
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+8963149
System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔值&同步完成)+
184



版本信息:Microsoft.NET Framework版本:4.0.30319;ASP.NET版本:4.0.30319.237

哇,今天遇到了完全相同的错误(但不确定这是否是同一个模块)

这是其中一个视图模型中的一个错误。有人在那里放置了一个接口而不是类(例如,IUser而不是UserPartRecord)。模型绑定器发出喊声,因为它无法创建要将表单参数绑定到的对象实例

您唯一的选择是将该参数的类型(您必须找到哪一个)更改为具体类型。最快的方法是创建一个实现该接口的简单类,并用它替换参数类型


编辑:讨论(并解决)了一个类似的问题。

我遇到了与(MVC 5)+(Ninject 3.2)完全相同的问题。整个DI准备工作非常典型和标准,无法正常工作。最后,我做到了:

  • 为你的控制器创建一个默认的CTOR
  • 在CTOR中,添加一行,如下所示:

    repository=DependencyResolver.Current.GetService(typeof(IYourinterface)) as IYourinterface;
    

  • 我知道这只是一个解决办法,但我认为MVC 5中关于控制器对象实例化的一些内容已经改变了。稍后我会将其挖掘出来。

    我开始在MVC ASP.Net 4.6应用程序中遇到这个异常。这花了我一些时间,但我最终意识到我已经从更改了MVC控制器API调用

    [HttpPost]
    public async Task<ActionResult> DoStuff(IEnumerable<string> ids){ ... }
    

    你试过联系该模块的作者吗?这看起来像一个bug报告,不是问题。是的,我试过了,但没有得到任何类型的支持。那太糟糕了。我想你唯一的选择就是修复他们的代码
    [HttpPost]
    public async Task<ActionResult> DoStuff(IReadOnlyList<string> ids){ ... }
    
    [MissingMethodException: Cannot create an instance of an interface.]
    System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean&amp; canBeCached, RuntimeMethodHandleInternal&amp; ctor, Boolean&amp; bNeedSecurityCheck) +0
    System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark) +119
    System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark) +247
    System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
    System.Activator.CreateInstance(Type type) +11
    System.Web.Mvc.DefaultModelBinder.CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) +197