IoC in Litium 8

We are upgrading a customer solution from Litium 7 to Litium 8. And we have noticed that IoC.Resolve dependency injection is no longer available. How can this be done in Litium 8?

We did this in seven because it was not possible to constructor inject ProductPriceModelBuilder. We had either circular references and/or empty objects when doing that.

1 Like

If you get circular dependency then you have not correct solution with usage of services. You might review the correct approach and maybe create new services to inject.

That’s what we have done in most cases. But there were some places where IoC.Resolve<> was a necessary evil. That’s why we’re looking for a direct replacement in Litium 8. As I recall there are even some IoC.Resolve<> in the Accelerator.

Since this is an upgrade our approach has been to

  • upgrade 1:1 (Litium 7 to Litium 8, .NET 4 to .NET 6)
  • do any changes/improvements (things that can be done better in Litium 8 or .NET 6)

You can access the service provider with injecting the System.IServiceProvider into you class. Adding the namespace Microsoft.Extensions.DependencyInjection and you will get typed extensions to resolve the services.

But remember to use the correct scope/lifetime of the service that is aware of the context to not reusing data in wrong context.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.