I am trying to register multiple implementations of the same interface like this :-
**DLL A: Module.cs**
_container.RegisterType<IFoo, Foo1>("Foo1");
**DLL B: Module.cs**
var childContainer = _container.CreateChildContainer(); //childcontainer
childContainer.RegisterType<IFoo, Foo2>("Foo2");
**DLL A: Resolve IFoo for Foo2** (But, resolving IFoo for Foo1 is fine)
var foo2 = container.Resolve<IFoo>("Foo2"); //Error
Note: The container which I receive here is the "childcontainer". Have checked the hashcode.
Error:
A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.Practices.Unity.dll
Additional information: The current type, IFoo, is an interface and cannot be constructed. Are you missing a type mapping?
But, it works, if I do the registration of Foo2 in DLL A just after Foo1 i.e. like this :
_container.RegisterType<IFoo, Foo1>("Foo1");
_container.RegisterType<IFoo, Foo2>("Foo2");
Is Registration (Register) and Resolution (Resolve)
dependent upon scope & assembly ? I want the 1st approach to work. Any idea ?