# IoC in Litium 8

**URL:** <https://forum.litium.com/t/ioc-in-litium-8/2624>\
**Category:** Questions\
**Tags:** litium-7, litium-8\
**Created:** [June 20, 2022, 11:19am UTC](https://forum.litium.com/t/ioc-in-litium-8/2624 "2022-06-20T11:19:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![KdxUrband](https://avatars.discourse-cdn.com/v4/letter/k/898d66/32.png) [@KdxUrband](https://forum.litium.com/u/KdxUrband)\
**Post date:** [June 20, 2022, 11:19am UTC](https://forum.litium.com/t/ioc-in-litium-8/2624/1 "2022-06-20T11:19:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [June 21, 2022, 7:47am UTC](https://forum.litium.com/t/ioc-in-litium-8/2624/2 "2022-06-21T07:47:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kdxperbol](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/kdxperbol/32/513_2.png) [@kdxperbol](https://forum.litium.com/u/kdxperbol)\
**Post date:** [June 21, 2022, 7:51am UTC](https://forum.litium.com/t/ioc-in-litium-8/2624/3 "2022-06-21T07:51:59Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [June 21, 2022, 1:43pm UTC](https://forum.litium.com/t/ioc-in-litium-8/2624/4 "2022-06-21T13:43:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [July 19, 2022, 1:44pm UTC](https://forum.litium.com/t/ioc-in-litium-8/2624/5 "2022-07-19T13:44:50Z")

</div>

Closed on July 19, 2022, 1:44pm UTC

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