I have some WinForms Singleton classes (with ContainerControlledLifetimeManager) in my UnityContainer which use several ParameterOverrides.
My Forms are resolved like this:
var form = Program.Container.Resolve<FormList>(new ParameterOverride("type", type));
I wrote a little extension to remove the instance from the UnityContainer when the WinForm closes, have a look:
public static void UnregisterInstance<T>(this IUnityContainer container) where T : class
var reg = container.Registrations.Where(e => e.RegisteredType == typeof(T)).FirstOrDefault();
if (reg != null)
// RemoveValue "automagically" calls Dispose on the object
Is there a way I can get the ContainerRegistration for a special instance with the specified ParameterOverride?