I've met an exception while resolving the object using Unity container:
Message "Value cannot be null.\r\nParameter name: container" Source "Microsoft.Practices.Unity" string
I have a Prism application where I have ServiceModule. ServiceModule just has interface and its implementation:
public interface ICommonService
{
string SomeStorage { get; set; }
}
public class CommonService : ICommonService
{
string fooStorage=DateTime.Now.ToString();
public string FooStorage
{
get
{
return fooStorage;
}
set
{
fooStorage = value;
OnPropertyChanged("FooStorage");
}
}
}
I create a single instance of ICommonService in ViewModelA of ModuleA. It works okay:
unityContainer = new UnityContainer();
unityContainer.RegisterType<ICommonService, CommonService>(new ContainerControlledLifetimeManager());
IMyService someFoo = unityContainer.Resolve<ICommonService>();
someFoo.FooStorage = "AAAOOOBBB";
Then I want to read this data in viewModelB of ModuleB. And this code throws an exception:
ICommonService someFoo = unityContainer.Resolve<ICommonService>();
string str=someFoo.FooStorage;
The exception says:
Message "Value cannot be null.\r\nParameter name: container" Source "Microsoft.Practices.Unity" string
What am I doing wrong? Any help will be greatly appreciated!
IMyServiceandMyService? - David ArnoICommonyServiceorIMyService? - Yacoub MassadviewModelB, how do you get an instance of the container? is the value ofunityContainernull? Can you debug to verify? - Yacoub Massad