C# 将Caliburn.Micro HelloScreens样本从Silverlight转换为WPF时出错

C# 将Caliburn.Micro HelloScreens样本从Silverlight转换为WPF时出错,c#,wpf,caliburn.micro,C#,Wpf,Caliburn.micro,我正在开发一个应用程序,它需要与Calibrun.Micro中HelloScreens示例几乎相同的功能。我已将代码转移到WPF应用程序,但当我尝试运行它时,在BootStrapper GetInstance方法中不断出现错误 找不到合同WpfApplication.Framework.IShell的任何实例。 我的配置是 protected override void Configure() { container = new CompositionContainer

我正在开发一个应用程序,它需要与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);
    }
受保护的覆盖无效配置()
{
容器=新合成容器(
新建AggregateCatalog(AssemblySource.Instance.Select(x=>new AssemblyCatalog(x)))
);
var batch=新的CompositionBatch();
AddExportedValue(新的WindowManager());
AddExportedValue(新的EventAggregator());
batch.AddExportedValue(容器);
容器。组成(批);
}

不确定这是国际奥委会的事还是什么。任何帮助都会很好。谢谢

这肯定与国际奥委会有关。如德里克所说,检查导出属性。请注意,如果您的ShellViewModel位于另一个程序集中,您还应该重写引导程序SelectAssemblys()方法。

它肯定与IoC相关。如德里克所说,检查导出属性。请注意,如果您的ShellViewModel位于另一个程序集中,您还应该重写引导程序SelectAssemblys()方法。

我终于找到了答案。我在配置中遗漏了这两行

 batch.AddExportedValue<Func<IMessageBox>>(() => _container.GetExportedValue<IMessageBox>());
 batch.AddExportedValue<Func<CustomerViewModel>>(() => _container.GetExportedValue<CustomerViewModel>());
batch.AddExportedValue(()=>_container.GetExportedValue());
batch.AddExportedValue(()=>_container.GetExportedValue());

我终于明白了。我在配置中遗漏了这两行

 batch.AddExportedValue<Func<IMessageBox>>(() => _container.GetExportedValue<IMessageBox>());
 batch.AddExportedValue<Func<CustomerViewModel>>(() => _container.GetExportedValue<CustomerViewModel>());
batch.AddExportedValue(()=>_container.GetExportedValue());
batch.AddExportedValue(()=>_container.GetExportedValue());

ShellViewModel仍有
[Export(typeof(IShell))]
?ShellViewModel仍有
[Export(typeof(IShell))]