启动时参数计数不匹配
Parameter count mismatch on startup
除了在 Startup.cs 代码执行完之后,我得到一个参数计数不匹配。如果在启动 class 退出时失败。但我无法弄清楚代码的下一步。它没有转到我的控制器。
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
var container = SimpleInjectorInitializer.Initialize(app);
ConfigureAuth(app, container);
}
}
Startup.Auth
public partial class Startup
{
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app, Container container)
{
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
app.CreatePerOwinContext(() => container.GetInstance<ApplicationUserManager>());
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));
app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);
}
}
堆栈跟踪:
[TargetParameterCountException: Parameter count mismatch.]
System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +11414282
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +54
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +21
WebActivator.BaseActivationMethodAttribute.InvokeMethod() +236
WebActivator.ActivationManager.RunActivationMethods() +370
WebActivator.ActivationManager.RunPostStartMethods() +41
WebActivator.StartMethodCallingModule.Init(HttpApplication context) +125
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +534
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +352
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Parameter count mismatch.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9947380
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261
我刚完成 ASP.NET.Identity 经理的注册,然后收到此错误。
有人知道为什么吗?
在你的喷油器的引擎盖下,它被称为
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
有两个参数,第一个是调用方法的目标实例,第二个是方法参数数组。
我们不知道您的上下文,但问题来自方法参数数组。那里发生了不匹配。参数计数不匹配。
使用调试,查看发生这种情况的位置并修复它,具体取决于您的上下文。
在简单的注入器中移除 WebActivator 组件
namespace WebApplication1.App_Start
{
using System.Reflection;
using System.Web.Mvc;
using SimpleInjector;
using SimpleInjector.Extensions;
using SimpleInjector.Integration.Web;
using SimpleInjector.Integration.Web.Mvc;
using Owin;
using Models;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Owin.Security.DataProtection;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using SimpleInjector.Advanced;
using Microsoft.Owin;
using System.Web;
using System.Collections.Generic;
public static class SimpleInjectorInitializer
{
}
它想要看起来像上面的代码
除了在 Startup.cs 代码执行完之后,我得到一个参数计数不匹配。如果在启动 class 退出时失败。但我无法弄清楚代码的下一步。它没有转到我的控制器。
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
var container = SimpleInjectorInitializer.Initialize(app);
ConfigureAuth(app, container);
}
}
Startup.Auth
public partial class Startup
{
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app, Container container)
{
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
app.CreatePerOwinContext(() => container.GetInstance<ApplicationUserManager>());
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));
app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);
}
}
堆栈跟踪:
[TargetParameterCountException: Parameter count mismatch.]
System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +11414282
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +54
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +21
WebActivator.BaseActivationMethodAttribute.InvokeMethod() +236
WebActivator.ActivationManager.RunActivationMethods() +370
WebActivator.ActivationManager.RunPostStartMethods() +41
WebActivator.StartMethodCallingModule.Init(HttpApplication context) +125
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +534
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +352
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Parameter count mismatch.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9947380
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261
我刚完成 ASP.NET.Identity 经理的注册,然后收到此错误。
有人知道为什么吗?
在你的喷油器的引擎盖下,它被称为
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
有两个参数,第一个是调用方法的目标实例,第二个是方法参数数组。
我们不知道您的上下文,但问题来自方法参数数组。那里发生了不匹配。参数计数不匹配。
使用调试,查看发生这种情况的位置并修复它,具体取决于您的上下文。
在简单的注入器中移除 WebActivator 组件
namespace WebApplication1.App_Start
{
using System.Reflection;
using System.Web.Mvc;
using SimpleInjector;
using SimpleInjector.Extensions;
using SimpleInjector.Integration.Web;
using SimpleInjector.Integration.Web.Mvc;
using Owin;
using Models;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Owin.Security.DataProtection;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using SimpleInjector.Advanced;
using Microsoft.Owin;
using System.Web;
using System.Collections.Generic;
public static class SimpleInjectorInitializer
{
}
它想要看起来像上面的代码