Best way to ensure something gets run before IDependency gets instantiated

I'd like to run some code (actually Autofac calls to register generic types, circumventing
this issue) before any IDependency (in my case, a service class) gets instantiated. What would you advise, where is the best place for this?

I'd like to register generic types that can be consumed by a service class which is an IDependency. I thought the best place is in a handler's ctor, and that's good if the module where the dependencies are registered and consumed is the same. However if
the registering module's name (where the handler is) comes after the consuming one's (where the service is) in the alphabet, than the handler gets instantiated after the service.

The Priority property in Module.txt doesn't seem to have any effect, although the module where the dependency is consumed is declared dependent on the module where the dependency is registered.

Thanks, although I haven't tried I think this would lead to the same problem: modules also have to be registered somewhere but I can't find a way to register anything before the service gets instantiated. Or were you hinting about something else?

Interesting ... I'd assumed at some point that Module/IModule were autowired, didn't realise they needed manual registration.

Well, IOrchardShellEvents is the earliest thing you can hook into. Generally not many IDependencies will have been instanced by that point (and Priority / dependencies could help you try and make yours run first I guess)

I was wrong, they get indeed picked up automatically. So dropping registrations in a simple module's Configure() works like a charm. Thank you very much, that'll come very handy. Also thanks for the IOrchardShellEvents tip, I think I'll need that one too.
(Interesting is that modules get instantiated earlier than IOrchardShellEvents Activation() runs.)