ошибка
От: merge  
Дата: 20.12.24 14:54
Оценка:
.net 8 core приложение. при запуске

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'.)
Re: ошибка
От: kov_serg Россия  
Дата: 20.12.24 18:41
Оценка:
Здравствуйте, merge, Вы писали:

M>.net 8 core приложение. при запуске

M> Как понять где ошибка?

https://learn.microsoft.com/en-us/aspnet/core/migration/50-to-60?view=aspnetcore-6.0&tabs=visual-studio#new-hosting-model

builder.Services.AddRazorPages();
Отредактировано 20.12.2024 18:43 kov_serg . Предыдущая версия .
Re[2]: ошибка
От: merge  
Дата: 22.12.24 11:42
Оценка:
Здравствуйте, kov_serg, Вы писали:

_>Здравствуйте, merge, Вы писали:


M>>.net 8 core приложение. при запуске

M>> Как понять где ошибка?

_>https://learn.microsoft.com/en-us/aspnet/core/migration/50-to-60?view=aspnetcore-6.0&tabs=visual-studio#new-hosting-model


_>builder.Services.AddRazorPages();


увы не помогло.
Но выявил один момент. у меня приложение как BackgroundService и при создании поставил don't use top level statements.
если сделать по старому шаблону приложение и не как BackgroundService то запускается
Re: ошибка
От: Alekzander  
Дата: 24.12.24 16:55
Оценка: -1 :)
Здравствуйте, 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.
Re[2]: ошибка
От: merge  
Дата: 25.12.24 12:46
Оценка:
Здравствуйте, Alekzander, Вы писали:



A>Наконец-то сишарп догнал сиплюсплюс.


в чем?
Re[3]: ошибка
От: amironov79  
Дата: 25.12.24 13:02
Оценка:
Здравствуйте, merge, Вы писали:

M>Но выявил один момент. у меня приложение как BackgroundService и при создании поставил don't use top level statements.

M>если сделать по старому шаблону приложение и не как BackgroundService то запускается

А шаблон какой? Консольного или web приложения?
Re[3]: ошибка
От: Alekzander  
Дата: 25.12.24 13:25
Оценка:
Здравствуйте, merge, Вы писали:

A>>Наконец-то сишарп догнал сиплюсплюс.


M>в чем?


В длине простыней.

(Это был образчик "грязного пошловатого юмора". Извините, не сдержался).
I'm a sewer mutant, and my favorite authors are Edgar Allan Poo, H.G. Smells and George R.R. Martin.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.