Error on type WebActivatorEx.ActivationManager threw an exception ....Parameter count mismatch
Asked Answered
B

1

5

I am getting this error after I installed Microsoft.Owin.*. Target .Net Framework:4.5.2. Web Activator: 2.2.0 I have the same setup in another project and that seems to work fine. Please help me debug or fix this.

Have I have done so far:-

  1. Updated all Nuget Packages
  2. Deleted obj folder contents
  3. Ran aspnet_compiler.exe -p C:\source\Application\MyAPI -v anything -errorstack . It did give the same error, but stopped after I added WebMatrix.data.

Full Error Details :-

Parameter count mismatch. 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.

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..]

Here's the 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" />
Balanced answered 14/6, 2017 at 18:2 Comment(0)
B
13

I found the issue. there was another PreApplicationStartMethod in swagger that was causing the issue. After I removed that line things started working.

Balanced answered 15/6, 2017 at 16:25 Comment(5)
"Parameter count mismatch" is really misleading. Thanks, saved my bacon!Messiah
@Balanced What do you mean by "there was another PreApplicationStartMethod in swagger"? Inside the SwaggerConfig.cs? where exactly?Civility
@k.explorer Don't know if you're still having the issue but at the top of SwaggerConfig.cs is a line [assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")] which can trigger this. That's what is referred to in this answer.Queer
Yes i noticed that after a couple of hours.Thanks for checking though.cheersCivility
"Parameter count mismatch" appears dead on to me (@StormMuller) in my case what I'd done is added an arg to the method described by the PreApplicationStartMethodAttribute. But I really had no idea from the error message itself that that was the cause since nothing in the error or stack trace points to a particular attribute. Point is: that's what triggers it but it shouldn't if the method signature is left as it originally was (in SwaggerConfig class shipped with Swashbuckle pre-netcore library). Best not to remove the attribute, at least if you expect it to automatically load Swagger.Undersecretary

© 2022 - 2024 — McMap. All rights reserved.