We have a windows application where we should be able to use the VariantService from Litium.Products, but the service seems to be not getting resolve successfully.
“InvalidOperationException: Unable to resolve service for type ‘Litium.Products.VariantService’ while attempting to activate ‘IntegrationService.Services.ProductService’.”
if I add service as below it gives another error "‘Cannot instantiate implementation type ‘Litium.Products.VariantService’ for service type ‘Litium.Products.VariantService’.’
"
‘Cannot instantiate implementation type ‘Litium.Data.Internal.IEntityService1[Litium.Products.Variant]' for service type 'Litium.Data.Internal.IEntityService1[Litium.Products.Variant]’.’
‘Cannot instantiate implementation type ‘Litium.Products.VariantService’ for service type ‘Litium.Data.Internal.IEntityService`1[Litium.Products.Variant]’.’
The Litium.Products.VariantService is the contract and for that the implementation need to be registrated so it is not so simple.
The implementation is dependent on a lot of other services, caching, configuration etc and to make it startup correctly you will add them with the services.AddLitiumApplication(Configuration);, this exists in the Litium.Application assembly. When adding the services.AddLitiumApplication(Configuration) into the services, the full Litium platform will be executed inside this application and not sure if that is what you want.
tried to add services.AddLitiumApplication(Configuration); but then I get error to add all the services highlighted, and still it fails if I add all those "‘Cannot instantiate implementation type ‘Litium.Connect.Shipments.ShippingProviderService’ for service type ‘Litium.Connect.Shipments.ShippingProviderService’.’
"
As for the VariantService, you can’t add the contract (abstract class) as the type for the service implementation and that is what you are doing with the yellow marked lines.
To solve that you have two options and both of them includes that you should remove the AddScoped-lines above and:
Remove the Litium.Connect.Abstractions assembly in the configuration for plugins
Add a package reference to Litium.Connect.Application
Added package reference to Litium.Connect.Application
only having this in start up now
it leads to an error “InvalidOperationException: Unable to resolve service for type ‘Microsoft.AspNetCore.Hosting.Server.IServer’ while attempting to activate ‘Litium.Application.Web.ServerListenerHelperServiceImpl’.” is there something I am missing?