What IoC setup should we use in Litium 7.x?

In Litium 7.x I have 2 options to setup my IoC:
IComponentInstaller and IApplicationConfiguration

What I do see between these 2 are that one are the standard Asp.Net IoC and the IComponentInstaller are using Castle Core. We are using both as we took over a project for a customer and now we have problem with how different services are getting resolved.

To my question, what way is the Litium way? Are they getting registered differently? Why are there 2 ways?
You could argue that the setup should be in the startup .exe in this context the MVC project as libraries shouldnt be dependent on a IoC library.

Litium version: 7.2

The reason that it exists two different versions is that the new IServiceProvider (managed from the IApplicationConfiguration) didn’t exists when we introduced Castle Windsor.

With Litium 5 we start the transformation to use the IServiceProvider that will be the future dependency container engine based on the standard aspnetcore version. Today they are both bounded together so the IServiceProvider are using the Castle Windsor but some of the registrations are working different between of the way (IComponentInstaller or IApplicationConfiguration) they are registered from and we have also solved some of the issues in the later versions than the 7.2 version.

So wich way is the “Litium” way to register services etc in the IoC?
There is also the Attribute way off doing it.

Can you give some guidelines on best way to go. Right now I have some requests that work and some are complaining about the objects have been disposed or used in other ways. Wich shows that Transient isent thread safe at the moment.

https://docs.litium.com/documentation/architecture/dependency-injection will cover the topics about how to register the components in different scenarios.

When application are starting the registration order are ServiceAttribute before the IApplicationConfiguration. Both of them are executed inside an IComponentInstaller and the result are then registered in Castle Windsor with all the other registrations.

All the component and services is accessible from all directions, exept the components that are registered as plugins, with the .AsPlugin() or the PluginAttribute, that only can be used with the IoC.ResolvePlugin-method and not injected as ctor’s-parameters into the services. Example of these services are the payment providers to ensure the backward compatibility with earlier version of Litium.

If the component are registered directly in the inner Castle Windsor container (Castle.Windsor.IWindsorContainer) the registration should be rewritten to use either the IComponentInstaller, IApplicationConfiguration or ServiceAttribute.

If you have some specific scenarios, please create a bug and we can investigate.

Thank you for that clarification. Makes it easier to understand.

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