Unable to run BookApp
DavidSSL opened this issue · comments
When I run the BookApp
project I get the following stack trace:
An error occurred while starting the application.
AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: BizDbAccess.Orders.IPlaceOrderDbAccess Lifetime: Transient ImplementationType: BizDbAccess.Orders.PlaceOrderDbAccess': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.) (Error while validating the service descriptor 'ServiceType: BizLogic.GenericInterfaces.IBizAction`2[BizLogic.Orders.PlaceOrderInDto,DataLayer.EfClasses.Order] Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderAction': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.) (Error while validating the service descriptor 'ServiceType: BizLogic.Orders.IPlaceOrderPart1 Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderPart1': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.) (Error while validating the service descriptor 'ServiceType: BizLogic.GenericInterfaces.IBizAction`2[BizLogic.Orders.PlaceOrderInDto,BizLogic.Orders.Part1ToPart2Dto] Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderPart1': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.) (Error while validating the service descriptor 'ServiceType: BizLogic.Orders.IPlaceOrderPart2 Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderPart2': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.) (Error while validating the service descriptor 'ServiceType: BizLogic.GenericInterfaces.IBizAction`2[BizLogic.Orders.Part1ToPart2Dto,DataLayer.EfClasses.Order] Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderPart2': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.) (Error while validating the service descriptor 'ServiceType: ServiceLayer.AdminServices.IAddReviewService Lifetime: Transient ImplementationType: ServiceLayer.AdminServices.Concrete.AddReviewService': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'ServiceLayer.AdminServices.Concrete.AddReviewService'.) (Error while validating the service descriptor 'ServiceType: ServiceLayer.AdminServices.IChangePriceOfferService Lifetime: Transient ImplementationType: ServiceLayer.AdminServices.Concrete.ChangePriceOfferService': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'ServiceLayer.AdminServices.Concrete.ChangePriceOfferService'.) (Error while validating the service descriptor 'ServiceType: ServiceLayer.AdminServices.IChangePubDateService Lifetime: Transient ImplementationType: ServiceLayer.AdminServices.Concrete.ChangePubDateService': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'ServiceLayer.AdminServices.Concrete.ChangePubDateService'.)
Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(IEnumerable<ServiceDescriptor> serviceDescriptors, IServiceProviderEngine engine, ServiceProviderOptions options)
InvalidOperationException: Error while validating the service descriptor 'ServiceType: BizDbAccess.Orders.IPlaceOrderDbAccess Lifetime: Transient ImplementationType: BizDbAccess.Orders.PlaceOrderDbAccess': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
InvalidOperationException: Error while validating the service descriptor 'ServiceType: BizLogic.GenericInterfaces.IBizAction`2[BizLogic.Orders.PlaceOrderInDto,DataLayer.EfClasses.Order] Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderAction': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
InvalidOperationException: Error while validating the service descriptor 'ServiceType: BizLogic.Orders.IPlaceOrderPart1 Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderPart1': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
InvalidOperationException: Error while validating the service descriptor 'ServiceType: BizLogic.GenericInterfaces.IBizAction`2[BizLogic.Orders.PlaceOrderInDto,BizLogic.Orders.Part1ToPart2Dto] Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderPart1': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
InvalidOperationException: Error while validating the service descriptor 'ServiceType: BizLogic.Orders.IPlaceOrderPart2 Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderPart2': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
InvalidOperationException: Error while validating the service descriptor 'ServiceType: BizLogic.GenericInterfaces.IBizAction`2[BizLogic.Orders.Part1ToPart2Dto,DataLayer.EfClasses.Order] Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderPart2': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
InvalidOperationException: Error while validating the service descriptor 'ServiceType: ServiceLayer.AdminServices.IAddReviewService Lifetime: Transient ImplementationType: ServiceLayer.AdminServices.Concrete.AddReviewService': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'ServiceLayer.AdminServices.Concrete.AddReviewService'.
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
InvalidOperationException: Error while validating the service descriptor 'ServiceType: ServiceLayer.AdminServices.IChangePriceOfferService Lifetime: Transient ImplementationType: ServiceLayer.AdminServices.Concrete.ChangePriceOfferService': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'ServiceLayer.AdminServices.Concrete.ChangePriceOfferService'.
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
InvalidOperationException: Error while validating the service descriptor 'ServiceType: ServiceLayer.AdminServices.IChangePubDateService Lifetime: Transient ImplementationType: ServiceLayer.AdminServices.Concrete.ChangePubDateService': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'ServiceLayer.AdminServices.Concrete.ChangePubDateService'.
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: BizDbAccess.Orders.IPlaceOrderDbAccess Lifetime: Transient ImplementationType: BizDbAccess.Orders.PlaceOrderDbAccess': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.) (Error while validating the service descriptor 'ServiceType: BizLogic.GenericInterfaces.IBizAction`2[BizLogic.Orders.PlaceOrderInDto,DataLayer.EfClasses.Order] Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderAction': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.) (Error while validating the service descriptor 'ServiceType: BizLogic.Orders.IPlaceOrderPart1 Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderPart1': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.) (Error while validating the service descriptor 'ServiceType: BizLogic.GenericInterfaces.IBizAction`2[BizLogic.Orders.PlaceOrderInDto,BizLogic.Orders.Part1ToPart2Dto] Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderPart1': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.) (Error while validating the service descriptor 'ServiceType: BizLogic.Orders.IPlaceOrderPart2 Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderPart2': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.) (Error while validating the service descriptor 'ServiceType: BizLogic.GenericInterfaces.IBizAction`2[BizLogic.Orders.Part1ToPart2Dto,DataLayer.EfClasses.Order] Lifetime: Transient ImplementationType: BizLogic.Orders.Concrete.PlaceOrderPart2': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'BizDbAccess.Orders.PlaceOrderDbAccess'.) (Error while validating the service descriptor 'ServiceType: ServiceLayer.AdminServices.IAddReviewService Lifetime: Transient ImplementationType: ServiceLayer.AdminServices.Concrete.AddReviewService': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'ServiceLayer.AdminServices.Concrete.AddReviewService'.) (Error while validating the service descriptor 'ServiceType: ServiceLayer.AdminServices.IChangePriceOfferService Lifetime: Transient ImplementationType: ServiceLayer.AdminServices.Concrete.ChangePriceOfferService': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'ServiceLayer.AdminServices.Concrete.ChangePriceOfferService'.) (Error while validating the service descriptor 'ServiceType: ServiceLayer.AdminServices.IChangePubDateService Lifetime: Transient ImplementationType: ServiceLayer.AdminServices.Concrete.ChangePubDateService': Unable to resolve service for type 'DataLayer.EfCode.EfCoreContext' while attempting to activate 'ServiceLayer.AdminServices.Concrete.ChangePubDateService'.)
Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(IEnumerable<ServiceDescriptor> serviceDescriptors, IServiceProviderEngine engine, ServiceProviderOptions options)
Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options)
Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder)
Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter<TContainerBuilder>.CreateServiceProvider(object containerBuilder)
Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
Microsoft.Extensions.Hosting.HostBuilder.Build()
BookApp.Program.Main(string[] args) in Program.cs
+
var host = CreateHostBuilder(args).Build();
BookApp.Program.<Main>(string[] args)
Would it be possible to get the code in shape so that we can run the application?
Hi @DavidSSL,
You didn't say which version you ran, but it looks like Part3
/ Part3-Net6
branch. I tried running both the Part3
(which works with .NET 5) and Part3-Net6
(which works with NET 6) and they both worked.
If you tried the Part3
make sure you have a .NET 5 SDK installed. Otherwise, have you changed anything? I looks like the DI parts had problems.
Hi @JonPSmith, my apologies but I had commented out some code in Startup
services.AddDbContext<EfCoreContext>( //#D
options => options.UseSqlServer(connection)); //#D
and of course that caused the problem. My apologies.