Caliburn.Micro在App.xaml的命名空间中没有“Bootstrapper”

编辑:似乎我终于让它工作了。 我问过我之前提到的那篇文章的作者,他说这是一个已知的问题。 他还给了mi一个解决方法(在post下方的评论中),所以我认为这个问题是封闭的。 但感谢大家花时间解决我的问题:)


我正在尝试使用Caliburn Micro框架学习MVVM,但我从一开始就遇到了问题。 我正在学习本教程,并在App.xaml中获得了这样的代码:

      

但是我收到了一个错误:

名称“Bootstrapper”在名称空间“clr-namespace:Caliburn”中不存在。

我从NuGet存储库获得了Caliburn Micro 1.5.2。 任何想法赞赏……

我的引导程序:

 using System; using System.Collections.Generic; using System.Linq; using System.Text; using Caliburn.Micro; namespace Caliburn { public class Bootstrapper : PhoneBootstrapper { PhoneContainer container; protected override void Configure() { container = new PhoneContainer(); container.RegisterPhoneServices(RootFrame); //container.PerRequest(); AddCustomConventions(); } static void AddCustomConventions() { //ellided } protected override object GetInstance(Type service, string key) { return container.GetInstance(service, key); } protected override IEnumerable GetAllInstances(Type service) { return container.GetAllInstances(service); } protected override void BuildUp(object instance) { container.BuildUp(instance); } } } 

您应该定义自己的Bootstrapper类型,该类型派生自Caliburn.Micro引导程序类型之一。 然后,应用程序资源中的资源应该是此引导程序的实例。

学习时最简单的选择是使用Caliburn.Micro.Start NuGet包 ,并查看其bootstrapper实现。 该文档还描述了您应该在App.xaml文件中使用的标记。

我想每个人都感到困惑,因为你命名了自己的命名空间caliburn所以他们认为你正在尝试创建框架引导程序的实例,所以我建议改变你的命名约定。 通过这种方式,而不是直接将引导程序放入应用程序资源中,尝试将其放入资源字典中,如下所示:

             

我有同样的问题,很容易解决。 您需要在Bootstrapper类和此方法集中覆盖方法OnStart,这是您的根视图。

 protected override void OnStartup(object sender, StartupEventArgs e) { DisplayRootViewFor(); }