Reputation: 4469
I just opened an application of which I need it's API to create the necessary data required for the application I'm actually working on.
On startup of the API I get this error:
System.MissingMethodException
HResult=0x80131513
Message=Method not found: 'Void Swashbuckle.Application.SwaggerDocsConfig.RootUrl(System.Func`2<System.Net.Http.HttpRequestMessage,System.String>)'.
Source=Scanner.Api
StackTrace:
at Scanner.Api.Configuration.SwaggerConfiguration.<>c.<ConfigureApiDocumentation>b__0_0(SwaggerDocsConfig c) in C:\MyApplication.Api\Configuration\SwaggerConfiguration.cs:line 176
at Swashbuckle.Application.HttpConfigurationExtensions.EnableSwagger(HttpConfiguration httpConfig, String routeTemplate, Action`1 configure)
at Scanner.Api.Configuration.SwaggerConfiguration.ConfigureApiDocumentation(HttpConfiguration httpConfiguration) in C:\MyApplication.Api\Configuration\SwaggerConfiguration.cs:line 13
at Scanner.Api.Startup.Configuration(IAppBuilder app, IdentityServerBearerTokenAuthenticationOptions identityServerBearerTokenAuthenticationOptions) in C:\MyApplication.Api\Startup.cs:line 61
The only thing that's changed is that my laptop has had a full Windows reinstall.
The code itself was cloned and no changes.
The SwaggerConfiguration mentioned above:
public static class SwaggerConfiguration
{
public static HttpConfiguration ConfigureApiDocumentation(this HttpConfiguration httpConfiguration)
{
httpConfiguration
.EnableSwagger("docs/{apiVersion}/swagger", c =>
{
c.RootUrl(RootUrlResolver);
c.SingleApiVersion("v1", "Scanner.Api");
var xmlCommentsFile = XmlCommentsFilePath();
if (File.Exists(xmlCommentsFile))
c.IncludeXmlComments(xmlCommentsFile);
c.DescribeAllEnumsAsStrings();
})
.EnableSwaggerUi("docs/{*assetPath}", c =>
{
c.DisableValidator();
});
return httpConfiguration;
}
private static string XmlCommentsFilePath()
{
var xmlCommentsPath = $"{AppDomain.CurrentDomain.BaseDirectory}\\bin\\Scanner.Api.xml";
return xmlCommentsPath;
}
private static string RootUrlResolver(HttpRequestMessage request)
{
var rootUrl = $"{request.RequestUri.GetLeftPart(UriPartial.Authority)}{request.GetRequestContext().VirtualPathRoot.TrimEnd('/')}";
return rootUrl;
}
}
What could cause this and what's the solution?
Update
I did an update-package to force every package to the latest version, followed by a delete of all bin
and obj
folders in the entire solution structure. Didn't fix the issue.
Upvotes: 2
Views: 4010
Reputation: 1150
Check the dependentAssemblies in the runtime section in your Web.config. There were some that were missing on the server and when I copied the ones from my local Web.config it resolved this error.
Upvotes: 0
Reputation: 1291
Try to recompile all your code and ensure that all the .dll files are the correct ones into the "bin" directory.
Upvotes: 3