我刚刚创建了一个新的asp net core 2.0应用程序,并添加了nuget的招摇。
当我尝试运行应用程序时,我在启用stdout日志后出现以下错误:
Application startup exception: System.MissingMethodException: Method not found: 'Void Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions.IncludeXmlComments(System.String)'.
at Ituran.Framework.Startup.StartupExtensions.<>c__DisplayClass10_0.<ConfigureServicesExtensions>b__7(SwaggerGenOptions c)
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Microsoft.Extensions.DependencyInjection.SwaggerGenServiceCollectionExtensions.CreateSwaggerProvider(IServiceProvider serviceProvider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass4_0.<UseMiddleware>b__0(RequestDelegate next)
at Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
crit: Microsoft.AspNetCore.Hosting.Internal.WebHost[6]
Application startup exception
System.MissingMethodException: Method not found: 'Void Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions.IncludeXmlComments(System.String)'.
at Ituran.Framework.Startup.StartupExtensions.<>c__DisplayClass10_0.<ConfigureServicesExtensions>b__7(SwaggerGenOptions c)
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Microsoft.Extensions.DependencyInjection.SwaggerGenServiceCollectionExtensions.CreateSwaggerProvider(IServiceProvider serviceProvider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass4_0.<UseMiddleware>b__0(RequestDelegate next)
at Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
Hosting environment: Localhost
Content root path: {PATH_OF_PROJECT}
Now listening on: http://localhost:23419
Application started. Press Ctrl+C to shut down.
这是我的Startup.cs
public class Startup
{
private StartupExtensions StartupExtensions { get; set; }
private IConfigurationRoot Configuration { get; set; }
public Startup(IHostingEnvironment env)
{
StartupExtensions = new StartupExtensions($"{env.EnvironmentName}");
Configuration = StartupExtensions.Init();
}
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
StartupExtensions.ConfigureServicesExtensions(services, Configuration, new SwaggerConfiguration
{
Title = "EmergencyEvent Api",
Version = "v1",
Description = "API de integração HDI"
}, false);
// Dependency Injection
services.AddScoped<IAuthenticationProvider, IturanAuthenticationProvider>();
services.AddScoped<IIturanAuthenticationService, IturanAuthenticationService>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
StartupExtensions.ConfigureExtensions(loggerFactory, app, Configuration, new SwaggerConfigurationUrl
{
ApiDevelopmentName = "api.emergencyevent",
ApiStagingName = "api.emergencyevent",
ApiProductionName = "api.emergencyevent"
});
}
}
我已尝试从startup.cs中删除swagger配置,但应用程序仍未运行。
答案 0 :(得分:0)
对我来说,解决方案(或解决方法)是将Swashbuckle从2.5降级到2.4(以前运行良好)。