Ah .. after scratching my head for several hours, I understood that :
container.RegisterCollection(typeof(IEventHandler<>), typeof(IEventHandler<>).Assembly);
RegisterCollection also handles open generics. Perhaps it should be registered somewhere.
EDIT:
I realized in the new documentation, this code is not a direct translation from RegisterManyForOpenGeneric. All that was done was to solve my compilation, but it did not register my handlers, I just checked it today.
Additional information: No registration for type
This is the correct version:
container.Register(typeof(IEventHandler<>), new[] { typeof(IEventHandler<>).Assembly });
Using RegisterCollection will require additional code changes (from the document):
Since we are registering a collection, we can no longer call container.GetInstance> (). Instead, instances can be obtained using the constructor argument IEnumerable> or by calling container.GetAllInstances> ().
What I have not done yet, and I really do not need to do this, since I do not have mixed open and non-generic ones. But I will explore this more in the future if I want to update my project.
source share