从 Visual Studio 运行我的项目时出现以下异常,它是一个 ASP.NET Core 项目。
似乎依赖项注册了两次,因此“System.ArgumentException:已添加具有相同键的项目”。
它似乎也与路线有关,但我找不到调试它的方法。
它似乎也与 Api 中的版本控制有关,因为如果我删除此代码,异常就会消失。
services.AddApiVersioning(o =>
{
o.AssumeDefaultVersionWhenUnspecified = true;
o.DefaultApiVersion = new ApiVersion(1, 0);
o.ReportApiVersions = true;
o.ApiVersionSelector = new CurrentImplementationApiVersionSelector(o);
});
任何人都见过这个或知道如何调试它。
Autofac.Core.DependencyResolutionException:在激活特定注册期间发生错误。有关详细信息,请参阅内部异常。注册:Activator = ISwaggerProvider (DelegateActivator), Services = [Swashbuckle.AspNetCore.Swagger.ISwaggerProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope 在激活特定注册过程中发生错误。有关详细信息,请参阅内部异常。注册:Activator = ApiDescriptionGroupCollectionProvider (ReflectionActivator), Services = [Microsoft.AspNetCore.Mvc.ApiExplorer.IApiDescriptionGroupCollectionProvider], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope 在激活特定注册过程中发生错误. 有关详细信息,请参阅内部异常。注册:Activator = IApiDescriptionProvider[] (DelegateActivator), Services = [System.Collections.Generic.IEnumerable
1[[Microsoft.AspNetCore.Mvc.ApiExplorer.IApiDescriptionProvider, Microsoft.AspNetCore.Mvc.Abstractions, Version=2.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]]], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = ExternallyOwned An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = DefaultApiDescriptionProvider (ReflectionActivator), Services = [Microsoft.AspNetCore.Mvc.ApiExplorer.IApiDescriptionProvider], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = DefaultInlineConstraintResolver (ReflectionActivator), Services = [Microsoft.AspNetCore.Routing.IInlineConstraintResolver], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.Extensions.Options.IOptions1[Microsoft.AspNetCore.Routing.RouteOptions])' 类型为'DefaultInlineConstraintResolver'。已添加具有相同密钥的项目。(详见内部异常。)(详见内部异常。)(详见内部异常。)(详见内部异常。)(详见内部异常。)(详见内部异常。)