c# – How to avoid giant main function because of dependency injection


I try to use dependency injection as often as I can but every time I end up with the same problem : I always have a giant main function.

If I use it without any framework and send the classes in the constructors, I have to initialize every class in the main and it can take quite a lot of lines.

If I use a framework with a inversion of control / a service locator the result is nearly the same because I have to initialize the classes and send them to the IOC.

Is there any way to use dependency injection without having a big giant function initializing everything ?