System.Delegate System.Reflection.MethodInfo.CreateDelegate(System.Type)

时间:2013-07-12 21:03:11

标签: c# asp.net-mvc ninject

据我所知,Ninject过去发生过这个错误,并且网站包的目标是4.x并且彼此不匹配。我已经检查了我的机器并且它们匹配 - 两者都是4.0。

我花了一些时间来更新项目中的所有Nu-Get包。在此之前,没有发生此错误。

如何消除此错误?

这是我的完整错误输出:

enter code here
'/'应用程序中的服务器错误。

找不到方法:'System.Delegate System.Reflection.MethodInfo.CreateDelegate(System.Type)'。 描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.MissingMethodException:找不到方法:'System.Delegate System.Reflection.MethodInfo.CreateDelegate(System.Type)'。

Source Error: 


Line 29:             DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
Line 30:             DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
Line 31:             bootstrapper.Initialize(CreateKernel);
Line 32:         }
Line 33: 


Source File: C:\My Documents\Alcon_DEV\SecurityMasterData\Dev\Alcon.SecurityMasterData.WebUI\App_Start\NinjectWebCommon.cs    Line: 31 

Stack Trace: 


[MissingMethodException: Method not found: 'System.Delegate System.Reflection.MethodInfo.CreateDelegate(System.Type)'.]
   Ninject.Injection.DynamicMethodInjectorFactory.Create(ConstructorInfo constructor) in c:\Projects\Ninject\ninject\src\Ninject\Injection\DynamicMethodInjectorFactory.cs:48
   Ninject.Planning.Strategies.ConstructorReflectionStrategy.Execute(IPlan plan) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Strategies\ConstructorReflectionStrategy.cs:67
   Ninject.Planning.<>c__DisplayClass1.<CreateNewPlan>b__0(IPlanningStrategy s) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Planner.cs:109
   Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map(IEnumerable`1 series, Action`1 action) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Language\ExtensionsForIEnumerableOfT.cs:32
   Ninject.Planning.Planner.CreateNewPlan(Type type) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Planner.cs:109
   Ninject.Planning.Planner.GetPlan(Type type) in c:\Projects\Ninject\ninject\src\Ninject\Planning\Planner.cs:71
   Ninject.Activation.Providers.StandardProvider.Create(IContext context) in c:\Projects\Ninject\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:77
   Ninject.Activation.Context.Resolve() in c:\Projects\Ninject\ninject\src\Ninject\Activation\Context.cs:157
   Ninject.<>c__DisplayClass10.<Resolve>b__c(IBinding binding) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:386
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +151
   System.Linq.<CastIterator>d__b1`1.MoveNext() +92
   System.Linq.Enumerable.Single(IEnumerable`1 source) +196
   Ninject.ResolutionExtensions.Get(IResolutionRoot root, IParameter[] parameters) in c:\Projects\Ninject\ninject\src\Ninject\Syntax\ResolutionExtensions.cs:37
   Ninject.Web.Mvc.NinjectMvcHttpApplicationPlugin.CreateDependencyResolver() in c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\NinjectMvcHttpApplicationPlugin.cs:83
   Ninject.Web.Mvc.NinjectMvcHttpApplicationPlugin.Start() in c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\NinjectMvcHttpApplicationPlugin.cs:54
   Ninject.Web.Common.Bootstrapper.<Initialize>b__0(INinjectHttpApplicationPlugin c) in c:\Projects\Ninject\Ninject.Web.Common\src\Ninject.Web.Common\Bootstrapper.cs:52
   Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map(IEnumerable`1 series, Action`1 action) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Language\ExtensionsForIEnumerableOfT.cs:32
   Ninject.Web.Common.Bootstrapper.Initialize(Func`1 createKernelCallback) in c:\Projects\Ninject\Ninject.Web.Common\src\Ninject.Web.Common\Bootstrapper.cs:52
   Alcon.SecurityMasterData.WebUI.App_Start.NinjectWebCommon.Start() in C:\My Documents\Alcon_DEV\SecurityMasterData\Dev\Alcon.SecurityMasterData.WebUI\App_Start\NinjectWebCommon.cs:31

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +0
   System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +72
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +335
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +28
   System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19
   WebActivatorEx.BaseActivationMethodAttribute.InvokeMethod() +241
   WebActivatorEx.ActivationManager.RunActivationMethods(Boolean designerMode) +611
   WebActivatorEx.ActivationManager.RunPreStartMethods(Boolean designerMode) +50
   WebActivatorEx.ActivationManager.Run() +80

[InvalidOperationException: The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +423
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +306
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +591

[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9010364
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256

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

1 个答案:

答案 0 :(得分:4)

.net 4.5中不存在该方法 - 在此之前,应该使用Delegate.CreateDelegate。听起来好像NInject在4.0 nuget包中错误地使用了该方法,在这种情况下你应该将其报告为NInject中的错误。

要做的第一件事是检查您使用的是正确版本的dll,即特别是4.0版本。

之后,其中一个:

  • 回滚到早期的NInject版本
  • 升级您的.net框架版本
  • 下载代码,修复代码并提交补丁