Reputation: 19843
I have this classes and interfaces
public interface IA{
void Load();
}
public interface IB : IA{
}
public class B : IB{
public void Load(){
//some code
}
}
and I register the IB
for type B
Microsoft Unity
resolves IB
to correct type which is B
, but when I try to call Load it shows an error IB does not contain a definition for 'Load'
This is my unity configuration
var unityContainer = new UnityContainer();
unityContainer.RegisterType<IB, B>();
var obj = unityContainer.Resolve<IB>();
obj.Load()
Upvotes: 0
Views: 481
Reputation: 1146
IB does not contain definition for Load() but IA does, so you either have to resolve IA to B via unity or once you resolve IB, cast it to IA.
Update 1: I have to agree with other folks here, that the OP code does work and resolve correctly with Unity (tested with .NET 4.5.2 and Unity 2.1.505.2). I am not sure why my suggestion above solved the OP issue, so there has to be some details omitted in the original question.
Update 2: Working Fiddle based on @will's https://dotnetfiddle.net/FoYQSM
Upvotes: 1