When you register an interface with As
Autofac does not automatically registers its base interfaces.
So you need to manually tell to Autofac that your DedicatedEventHandler
is also an IEventHandler
with:
builder.RegisterType<DedicatedEventHandler>()
.As<IEventHandler<ISomeClass>>()
.As<IEventHandler>();
If you want to register a type with all its interfaces you can use the AsImplementedInterfaces
method.
So the equivalent of the above registration is the following:
builder.RegisterType<DedicatedEventHandler>()
.AsImplementedInterfaces();