Unity: Replace registered type with another type at runtime

The method RegisterInstance of the UnityContainer will always override the last registration entry if you do not distinguish them by name.

So if you call

container.RegisterInstance<IHardware>(new HardwareB());

you will override the registration for the interface IHardware and will retreive HardwareB on the next resolving attempt

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)