Hi, I'm migrating from Umbraco 7 to 8 and I'm using Autofac as my dependency injection framework, but actually Umbraco 8 came with LightInject as a built in dependency injection library.
Does that mean that I need to use LightInject instead and refactor all my code to adapt to this? I believe there should be a way so that we can use our preferred DI framework but I couldn't find any in the documentatio?
Thanks Dav, I'm quite disappointed as it should be normal to configure another DI framework without such customizations. I hope they take that into consideration in the upcoming releases.
For V9 they are using MS DI. So no external DI framework is used there.
Can I ask why you want to use Autofac, instead of the default Umbraco setup.
When working on V7 projects in the past I also used Autofac. But when we switched over to V8 I always used the built in container (LightInject). Having built over 50 websites on V8 I never had any issues with that. I even never needed to access the concrete container, but only used the Umbraco API to register dependencies.
Hi David,
As you mentioned I'm already using Autofac in my project and I don't have any issues with it at the moment. I didn't dig deep the exact differences between both frameworks. Just not comfortable with the idea that we need to change our DI framework just because Umbraco doesn't support that out of the box. It's unnecessary code change from my point of view.
Even in .Netcore you can use the default DI or your preferred one without doing customizations .
Using Umbraco 8 with Autofac
Hi, I'm migrating from Umbraco 7 to 8 and I'm using Autofac as my dependency injection framework, but actually Umbraco 8 came with LightInject as a built in dependency injection library.
Does that mean that I need to use LightInject instead and refactor all my code to adapt to this? I believe there should be a way so that we can use our preferred DI framework but I couldn't find any in the documentatio?
Hi Mahmoud,
In theory it should be possible to replace light inject by autofac (I think), by creating your own implementation of the IRegister interface : https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/src/Umbraco.Core/Composing/IRegister.cs
This is the Light Inject implementation : https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/src/Umbraco.Core/Composing/LightInject/LightInjectContainer.cs
You then need to tell Umbraco to use it by setting some app settings : https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/src/Umbraco.Core/Composing/RegisterFactory.cs#L24
But honestly, I think the safer and quicker solution is to use the default umbraco DI setup.
Dave
Thanks Dav, I'm quite disappointed as it should be normal to configure another DI framework without such customizations. I hope they take that into consideration in the upcoming releases.
Hi Mahmoud,
For V9 they are using MS DI. So no external DI framework is used there.
Can I ask why you want to use Autofac, instead of the default Umbraco setup.
When working on V7 projects in the past I also used Autofac. But when we switched over to V8 I always used the built in container (LightInject). Having built over 50 websites on V8 I never had any issues with that. I even never needed to access the concrete container, but only used the Umbraco API to register dependencies.
Dave
Hi David, As you mentioned I'm already using Autofac in my project and I don't have any issues with it at the moment. I didn't dig deep the exact differences between both frameworks. Just not comfortable with the idea that we need to change our DI framework just because Umbraco doesn't support that out of the box. It's unnecessary code change from my point of view. Even in .Netcore you can use the default DI or your preferred one without doing customizations .
is working on a reply...