C# 无法生成Caliburn Micro教程代码。“AssemblySource.Select”没有定义

C# 无法生成Caliburn Micro教程代码。“AssemblySource.Select”没有定义,c#,wpf,caliburn.micro,C#,Wpf,Caliburn.micro,我正试图开始学习Caliburn Micro的教程 但是,教程中的代码会产生错误。在该页面上,提供了以下引导程序代码: using Caliburn.Micro; using System.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; using System.ComponentModel.Composition.Primitives; public class AppBootstrap

我正试图开始学习Caliburn Micro的教程

但是,教程中的代码会产生错误。在该页面上,提供了以下引导程序代码:

using Caliburn.Micro;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;

public class AppBootstrapper : Bootstrapper<AppViewModel>
{
  private CompositionContainer container;

  protected override void Configure()
  {
    container = new CompositionContainer(new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>()));

    CompositionBatch batch = new CompositionBatch();

    batch.AddExportedValue<IWindowManager>(new WindowManager());
    batch.AddExportedValue<IEventAggregator>(new EventAggregator());
    batch.AddExportedValue(container);

    container.Compose(batch);
  }

  protected override object GetInstance(Type serviceType, string key)
  {
    string contract = string.IsNullOrEmpty(key) ? AttributedModelServices.GetContractName(serviceType) : key;
    var exports = container.GetExportedValues<object>(contract);

    if (exports.Count() > 0)
    {
      return exports.First();
    }

    throw new Exception(string.Format("Could not locate any instances of contract {0}.", contract));
  }
}
我找不到泛型类或其他称为Bootstrapper的类,但我已经能够扩展BootstrapperBase了

然而,我在申报集装箱的线路上遇到了麻烦。AssemblySource没有名为Select的方法


那么是什么原因呢?这是版本2.0和1.0之间的差异吗?如果有,我是否可以遵循一些更新的学习材料

在1.5.2和2.0.0之间有一些突破性的变化。其中大部分内容在附录中概述。尽管看起来对引导程序的更改丢失了。这应该很快得到解决

您应该继承Bootstrapper,并添加如下方法,而不是继承Bootstrapper

protected override void OnStartup(object sender, StartupEventArgs e)
{
    DisplayRootViewFor<AppViewModel>();
}
给你的引导者


缺少方法Select是因为AssemblySource.Instance是IObservableCollection,而Select方法是LINQ扩展方法。添加using for System.Linq将更正该错误。

在1.5.2和2.0.0之间有一些突破性的更改。其中大部分内容在附录中概述。尽管看起来对引导程序的更改丢失了。这应该很快得到解决

您应该继承Bootstrapper,并添加如下方法,而不是继承Bootstrapper

protected override void OnStartup(object sender, StartupEventArgs e)
{
    DisplayRootViewFor<AppViewModel>();
}
给你的引导者


缺少方法Select是因为AssemblySource.Instance是IObservableCollection,而Select方法是LINQ扩展方法。添加using for System.Linq将更正该错误。

我相信您是想从Bootstrapper数据库继承,而不是从Bootstrapper。此外,我无法运行我的应用程序。我添加了:public AppBootstrapper{Initialize;}我相信您是想从Bootstrapper数据库继承,而不是从Bootstrapper。另外,我无法运行我添加的应用程序:public AppBootstrapper{Initialize;}