В моем App.xaml.cs у меня есть
private void InitializeContainer()
{
var catalogs = new AggregateCatalog();
var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
catalogs.Catalogs.Add(catalog);
// Also adding Interactions project
catalog = new AssemblyCatalog(typeof(InteractionsService).Assembly);
catalogs.Catalogs.Add(catalog);
// initialize the main application composition host (container)
CompositionHost.Initialize(catalogs);
}
Тем не менее, когда я пытаюсь инициализировать объект в следующей строке:
this.InteractionsService = ServiceLocator.Current.GetInstance<IInteractionsService>();
Я получаю исключение, что мой ServiceLocator.Current равен нулю.
Как мне заставить это работать?