Swashbuckle.AspNetCore: Swashbuckle.AspNetCore not working with new release of .netcore 3.0 as of 09/25

Runtime exception on IWebHostBuilder CreateWebHostBuilder(string[] args):

An error occurred while starting the application. MissingMethodException: Method not found: ‘Void Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware…ctor(Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Hosting.IHostingEnvironment, Microsoft.Extensions.Options.IOptions`1<Microsoft.AspNetCore.Builder.StaticFileOptions>, Microsoft.Extensions.Logging.ILoggerFactory)’. Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.CreateStaticFileMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, ILoggerFactory loggerFactory, SwaggerUIOptions options)

MissingMethodException: Method not found: ‘Void Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware…ctor(Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Hosting.IHostingEnvironment, Microsoft.Extensions.Options.IOptions`1<Microsoft.AspNetCore.Builder.StaticFileOptions>, Microsoft.Extensions.Logging.ILoggerFactory)’. Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.CreateStaticFileMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, ILoggerFactory loggerFactory, SwaggerUIOptions options) Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware…ctor(RequestDelegate next, IHostingEnvironment hostingEnv, ILoggerFactory loggerFactory, SwaggerUIOptions options) System.RuntimeMethodHandle.InvokeMethod(object target, object[] arguments, Signature sig, bool constructor, bool wrapExceptions) System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) Microsoft.Extensions.Internal.ActivatorUtilities+ConstructorMatcher.CreateInstance(IServiceProvider provider) Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, object[] parameters) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+<>c__DisplayClass4_0.<UseMiddleware>b__0(RequestDelegate next) Microsoft.AspNetCore.Builder.ApplicationBuilder.Build() Microsoft.AspNetCore.Hosting.WebHost.BuildApplication() Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken) Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, string startupMessage) Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, string startupMessage) Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token) Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host) WebAPIApplication.Program.Main(string[] args) in Program.cs + CreateWebHostBuilder(args).Build().Run();

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 18
  • Comments: 27 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Install-Package Swashbuckle.AspNetCore -Version 5.0.0-rc4

and change services to:

c.SwaggerDoc(“v1”, new Microsoft.OpenApi.Models.OpenApiInfo { Title = “Core API”, Description = “Swagger Core API” });

I had the same issue with Swashbuckle.AspNetCore 4.0.0. Upgrade to 5.0.0.-rc3 solved it.

Works for me as well upgrading to rc4. Just need to tweak The “Info” object from swagger to “OpenApiInfo”

Swashbuckle.AspNetCore.SwaggerGen 5.0.0-rc4 is still referencing Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 3.0.0-preview3-19153-02) which is still Preview3 and not 3.0.0.

I can second this, upgrade to .NET Core 3.0 (ASP.NET Core) yesterday and I am facing the same issue.

Install package Microsoft.OpenApi and Swashbuckle.AspNetCore -Version 5.0.0-rc4: Keep only your defined endpoints.

Running now in NET Core 3.1 https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-3.1&tabs=visual-studio

Could someone on this thread please put together a minimal application (from scratch) that repro’s the issue and post it on GitHub. I have lots of examples (and tests) of rc3 working with .NET Core 3.0 so just saying it doesn’t work isn’t particularly helpful in terms of finding a solution. If someone posts the minimal repro application, then I’ll take a look and maybe we can get somewhere. Thanks

I had the same issue with Swashbuckle.AspNetCore 4.0.0. Upgrade to 5.0.0.-rc3 solved it.

It might fix the issue but it also introduces breaking changes. No solution to the issue from my point of view.

4x will not be supporting NET Core 3.0

I upgrade Swashbuckle.AspNetCore 5.0.0-rc3 to rc4 and works!

To clarify, I received the error originally posted above. I was upgrading a web api app from ASP.NET Core 2.2 to ASP.NET Core 3.0, not sure if that is related. I do not have time to create a repro until Saturday or Sunday…

In net core 3.0,I had the same issue with Swashbuckle.AspNetCore 4.0.0. Upgrade to 5.0.0.-rc3 can not solved it.

I also had to tweek the implementation of SwaggerDefaultValues class to accomodate the new IOperationFilter. (uses OpenApi in the same manner as the Info object @cmarrades mentions)

I get this. I don’t know if it’s the same as the others. Repro steps:

  1. Create a new API template project in VS 2019 pro16.3.1.
  2. In the pm console type: Install-Package Swashbuckle.AspNetCore -Version 5.0.0-rc3
  3. Run

Severity Code Description Project File Line Suppression State Error MSB3073 The command "dotnet “C:\Users\XXXX.nuget\packages\microsoft.extensions.apidescription.server\0.3.0-preview7.19365.7\build/…/tools/dotnet-getdocument.dll” --assembly “C:\Users\XXXX\source\repos\SwashBuckleExample\SwashBuckleExample\bin\Debug\netcoreapp3.0\SwashBuckleExample.dll” --file-list “obj\SwashBuckleExample.OpenApiFiles.cache” --framework “.NETCoreApp,Version=v3.0” --output “obj” --project “SwashBuckleExample” --assets-file “C:\Users\XXXX\source\repos\SwashBuckleExample\SwashBuckleExample\obj\project.assets.json” --platform “AnyCPU” " exited with code 6. SwashBuckleExample C:\Users\XXXX.nuget\packages\microsoft.extensions.apidescription.server\0.3.0-preview7.19365.7\build\Microsoft.Extensions.ApiDescription.Server.targets 41

I had a API template that I made just to make future projects more easy to go and it was running on Core 2.2.

Today I decided to up this to Core 3.0 also I update Swash to rc3 and now I’m expecting the following error:

Severity Code Description Project File Line Suppression State Suppression State Error MSB3073 The command "dotnet “C:\Users\andre.nuget\packages\microsoft.extensions.apidescription.server\0.3.0-preview7.19365.7\build/…/tools/dotnet-getdocument.dll” --assembly “C:\Workspace\diretor-cash\src\Diretor.Cash\Diretor.Cash.Api\bin\Debug\netcoreapp3.0\Diretor.Cash.Api.dll” --file-list “obj\Diretor.Cash.Api.OpenApiFiles.cache” --framework “.NETCoreApp,Version=v3.0” --output “obj” --project “Diretor.Cash.Api” --assets-file “C:\Workspace\diretor-cash\src\Diretor.Cash\Diretor.Cash.Api\obj\project.assets.json” --platform “AnyCPU” " exited with code 6. Diretor.Cash.Api C:\Users\andre.nuget\packages\microsoft.extensions.apidescription.server\0.3.0-preview7.19365.7\build\Microsoft.Extensions.ApiDescription.Server.targets 41