I have the following class and interface definitions:
interface IView { ... }
interface IViewA : IView { ... }
interface IViewB : IView { ... }
class ViewA : IViewA { ... }
class ViewB : IViewB { ... }
class Controller
{
public Controller(IViewA view) { ... }
}
And I register them in the unity container like this:
unityContainer.RegisterSingleton<IViewA, ViewA>("TheTestViewA");
unityContainer.RegisterSingleton<IViewB, ViewB>("TheTestViewB");
unityContainer.RegisterSingleton<Controller>();
However when I then request the instance of the controller, unity throws an exception.
unityContainer.Resolve<Controller>();
Resolution failed with error: No public constructor is available for type IViewA.
It seems that it wants to construct the interface and not the class. I also found out, that when I omit the naming parameter "TheTestViewA" it works fine. However I need that parameter because later on I need to container.ResolveAll<IView>() which only works when the mapping has a name. ( ResolveAll not working )