I've written a class that has some dependencies it resolves from the unity container.
From my main class I create a new object
MyObject myObject = new MyObject();
I register it with my Unity Container
UContainer.RegisterInstance<MyObject>(myObject, new ExternallyControlledLifetimeManager());
the I create the type that needs this as a dependency
ConsumerObject consumer = new ConsumerObject();
the consumer looks like this:
public class ConsumerObject
{
public ConsumberObject()
{
theObject = (MyObject)UContainer.Resolve(typeof(MyObject));
}
}
this throws an exception: Resolution of the dependency failed, type = "MyObject", name = "". Exception message is: The current build operation (build key Build Key[MyObject, null]) failed: The parameter pp could not be resolved when attempting to call constructor MyObject(IPreferenceStorageProvider pp). (Strategy type BuildPlanStrategy, index 3)
Why is my resolve call trying to call another contsructor on the type? I already created it and registered the instance.. I also tried it like: theObject = UContainer.Resolve<MyObject>();
doesn't seem to make any difference..
Thanks