1
我创建了一个从BootstrapperBase
派生的类,覆盖了OnStartup()
,并调用DisplayRootViewFor<AppViewModel>()
,就像在文档中一样。DisplayRootViewFor上的NullReferenceException <>
但是,当我启动应用程序,我得到一个NullReferenceException
上DisplayRooViewFor<AppViewModel>()
using Caliburn.Micro;
using MHBRestore.Logic;
using MHBRestore.UI.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace MHBRestore.UI
{
public class AppBootstrapper : BootstrapperBase
{
private SimpleContainer _container = new SimpleContainer();
public AppBootstrapper()
{
Initialize();
}
protected override void OnStartup(object sender, StartupEventArgs e)
{
DisplayRootViewFor<AppViewModel>();
}
protected override object GetInstance(Type service, string key)
{
return _container.GetInstance(service, key);
}
protected override IEnumerable<object> GetAllInstances(Type service)
{
return _container.GetAllInstances(service);
}
protected override void BuildUp(object instance)
{
_container.BuildUp(instance);
}
}
}