C
C#2y ago
FanLife

Dependency injection with multi project

Hi I have asp.net project and a console project which is in the same solution. I would like to launch a method which is in my console project but I want to launch it in asp.net. The problem is that the method I need to run need a dependency injection. How should I do it, because for the future I need to recall more methods between the two. in summary how can i manage dependency injection in multi project
2 Replies
Yawnder
Yawnder2y ago
You add a dependency from the main project to the auxiliary project and have that project do it's registrations in the same IServiceCollection.
Mayor McCheese
In complex cases between projects I’ll create an extension method to simplify di for the guest project. E.g services.AddMerchantServices()