我正在开发一款需要与Calibrun.Micro的HelloScreens样本功能相同的应用程序。我将代码转移到WPF应用程序但是当我尝试运行它时,我一直在BootStrapper GetInstance方法中出现错误
无法找到合同WpfApplication.Framework.IShell的任何实例。
我的配置是
protected override void Configure()
{
container = new CompositionContainer(
new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)))
);
var batch = new CompositionBatch();
batch.AddExportedValue<IWindowManager>(new WindowManager());
batch.AddExportedValue<IEventAggregator>(new EventAggregator());
batch.AddExportedValue(container);
container.Compose(batch);
}
不确定它是否属于IoC或什么。任何帮助都会很棒。感谢!!!
答案 0 :(得分:1)
好吧,我终于明白了。我在配置
中缺少这两行 batch.AddExportedValue<Func<IMessageBox>>(() => _container.GetExportedValue<IMessageBox>());
batch.AddExportedValue<Func<CustomerViewModel>>(() => _container.GetExportedValue<CustomerViewModel>());
答案 1 :(得分:0)
这绝对与IoC有关。 Derek说,检查Export属性。请注意,如果您的ShellViewModel位于另一个程序集中,您还应该覆盖bootstrappers SelectAssemblies()方法。