5

安装 Microsoft.Owin.* 后出现此错误。目标 .Net 框架:4.5.2。Web Activator: 2.2.0 我在另一个项目中有相同的设置,而且似乎工作正常。请帮我调试或解决这个问题。

到目前为止我做过吗:-

  1. 更新了所有 Nuget 包
  2. 已删除 obj 文件夹内容
  3. 跑 aspnet_compiler.exe -p C:\source\Application\MyAPI -v anything -errorstack 。它确实给出了同样的错误,但在我添加 WebMatrix.data 后停止了。

完整的错误详细信息:-

参数计数不匹配。说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

Stack Trace: 
[TargetParameterCountException: Parameter count mismatch.]
System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, 
BindingFlags invokeAttr, Binder binder,    Object[] parameters, CultureInfo 
culture) +11403690
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags 
invokeAttr, Binder binder, Object[]    parameters, CultureInfo culture) +54
WebActivatorEx.BaseActivationMethodAttribute.InvokeMethod() +73
WebActivatorEx.ActivationManager.RunActivationMethods(Boolean designerMode) 
+637
WebActivatorEx.ActivationManager.Run() +103

[InvalidOperationException: The pre-application start initialization method 
Run on type    WebActivatorEx.ActivationManager threw an exception with the 
following error message: Parameter count    mismatch..]

这是 package.config :-

  <package id="EntityFramework" version="6.1.3" targetFramework="net452" />
  <package id="log4net" version="2.0.8" targetFramework="net452" />
  <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebApi.Owin" version="5.2.3" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebHelpers" version="3.2.3" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebPages.Data" version="3.2.3" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebPages.WebData" version="3.2.3" targetFramework="net452" />
  <package id="Microsoft.Owin" version="3.1.0" targetFramework="net452" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="3.1.0" targetFramework="net452" />
  <package id="Microsoft.Owin.Security" version="3.1.0" targetFramework="net452" />
  <package id="Microsoft.Owin.Security.OAuth" version="3.1.0" targetFramework="net452" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
  <package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" />
  <package id="Owin" version="1.0" targetFramework="net452" />
  <package id="Swashbuckle" version="5.5.3" targetFramework="net452" />
  <package id="Swashbuckle.Core" version="5.5.3" targetFramework="net452" />
  <package id="WebActivatorEx" version="2.0" targetFramework="net452" />
4

1 回答 1

13

我发现了这个问题。招摇中还有另一个 PreApplicationStartMethod 导致了这个问题。在我删除那条线之后,事情开始起作用了。

于 2017-06-15T16:25:40.840 回答