var builder = Host.CreateApplicationBuilder(args);
var host = builder.Build();
host.Run();
получаю такую ошибку. Как понять где ошибка?
System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder Lifetime: Transient ImplementationType: Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder': Unable to resolve service for type 'System.Diagnostics.DiagnosticSource' while attempting to activate 'Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorCollectionProvider Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider': Unable to resolve service for type 'System.Diagnostics.DiagnosticSource' while attempting to activate 'Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.Infrastructure.IActionSelector Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.Infrastructure.ActionSelector': Unable to resolve service for type 'System.Diagnostics.DiagnosticSource' while attempting to activate 'Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.ActionConstraints.ActionConstraintCache Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.ActionConstraints.ActionConstraintCache': Unable to resolve service for type 'System.Diagnostics.DiagnosticSource' while attempting to activate 'Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Routing.MatcherPolicy Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.Routing.ActionConstraintMatcherPolicy': Unable to resolve service for type 'System.Diagnostics.DiagnosticSource' while attempting to activate 'Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.Infrastructure.IActionInvokerFactory Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.Infrastructure.ActionInvokerFactory': No constructor for type 'Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerProvider' can be instantiated using services from the service container and default values.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.Abstractions.IActionInvokerProvider Lifetime: Transient ImplementationType: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerProvider': No constructor for type 'Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerProvider' can be instantiated using services from the service container and default values.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.Infrastructure.IActionResultExecutor`1[Microsoft.AspNetCore.Mvc.VirtualFileResult] Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.Infrastructure.VirtualFileResultExecutor': Unable to resolve service for type 'Microsoft.AspNetCore.Hosting.IWebHostEnvironment' while attempting to activate 'Microsoft.AspNetCore.Mvc.Infrastructure.VirtualFileResultExecutor'.)
увы не помогло.
Но выявил один момент. у меня приложение как BackgroundService и при создании поставил don't use top level statements.
если сделать по старому шаблону приложение и не как BackgroundService то запускается
Здравствуйте, merge, Вы писали:
M>получаю такую ошибку. Как понять где ошибка? M> M>System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder Lifetime: Transient ImplementationType: Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder': Unable to resolve service for type 'System.Diagnostics.DiagnosticSource' while attempting to activate 'Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.Infrastructure.IActionDescriptorCollectionProvider Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider': Unable to resolve service for type 'System.Diagnostics.DiagnosticSource' while attempting to activate 'Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.Infrastructure.IActionSelector Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.Infrastructure.ActionSelector': Unable to resolve service for type 'System.Diagnostics.DiagnosticSource' while attempting to activate 'Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.ActionConstraints.ActionConstraintCache Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.ActionConstraints.ActionConstraintCache': Unable to resolve service for type 'System.Diagnostics.DiagnosticSource' while attempting to activate 'Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Routing.MatcherPolicy Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.Routing.ActionConstraintMatcherPolicy': Unable to resolve service for type 'System.Diagnostics.DiagnosticSource' while attempting to activate 'Microsoft.AspNetCore.Mvc.Razor.RazorPageActivator'.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.Infrastructure.IActionInvokerFactory Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.Infrastructure.ActionInvokerFactory': No constructor for type 'Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerProvider' can be instantiated using services from the service container and default values.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.Abstractions.IActionInvokerProvider Lifetime: Transient ImplementationType: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerProvider': No constructor for type 'Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerProvider' can be instantiated using services from the service container and default values.) (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Mvc.Infrastructure.IActionResultExecutor`1[Microsoft.AspNetCore.Mvc.VirtualFileResult] Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Mvc.Infrastructure.VirtualFileResultExecutor': Unable to resolve service for type 'Microsoft.AspNetCore.Hosting.IWebHostEnvironment' while attempting to activate 'Microsoft.AspNetCore.Mvc.Infrastructure.VirtualFileResultExecutor'.)
Наконец-то сишарп догнал сиплюсплюс.
I'm a sewer mutant, and my favorite authors are Edgar Allan Poo, H.G. Smells and George R.R. Martin.
Здравствуйте, merge, Вы писали:
M>Но выявил один момент. у меня приложение как BackgroundService и при создании поставил don't use top level statements. M>если сделать по старому шаблону приложение и не как BackgroundService то запускается