我应该创建什么而不是引导程序?棱镜6.1.0



我已经尝试将我的应用程序从Prism v4.0更新到Prism v6.1.0,并运行包管理器:PM>安装封装棱镜核心

PM安装了这样的软件包:

  • Microsoft.Practices.Prism.Composition.dll
  • Microsoft.Practices.Prism.Interactivity.dll
  • Microsoft.Practices.Prism.Mvvm.dll
  • Microsoft.Practices.Prism.Mvvm.Desktop.dll
  • Microsoft.Practices.Prism.PubSubEvents.dll
  • Microsoft.Practices.Prism.SharedInterfaces.dll
  • Microsoft.Practices.ServiceLocation.dll

我尝试创建引导程序的下一步:

public class Bootstrapper : UnityBootstrapper
{
    protected override DependencyObject CreateShell()
    {
        return Container.Resolve<Shell>();
    }
    protected override void InitializeShell()
    {
        base.InitializeShell();
        App.Current.MainWindow = (Window)Shell;
        App.Current.MainWindow.Show();
    }
    protected override void ConfigureContainer()
    {
        base.ConfigureContainer();
        Container.RegisterType<IShellViewModel, ShellViewModel>();
    }     
    protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
    {
        RegionAdapterMappings mappings = base.ConfigureRegionAdapterMappings();
        mappings.RegisterMapping(typeof(StackPanel), Container.Resolve<StackPanelRegionAdapter>());
        return mappings;
    } 
    protected override IModuleCatalog CreateModuleCatalog()
    {
        ModuleCatalog catalog = new ModuleCatalog();            
        catalog.AddModule(typeof(ModuleBModule));
        return catalog;
    }
}

并且我已经尝试解决CCD_ 1。然而,在Prism 6.1.0中没有这样的类。所以我尝试通过Nuget:安装

Prism.UnityExtesions

然而NuGet说:This package is no longer supported. Please use the new Prism.Unity package

Prism 5.0提供了一个引导程序类。但是现在不支持Prism 5.0。例如,在本例中,来自code.msdn.的HelloWorld

因此,我想到了一个问题:如何在Prism 6.1.0中创建引导程序

正如@toumir在评论中提到的,首先卸载所有Microsoft.Practices.*软件包(检查您的软件包配置以确保它们都已卸载)。

由于您正尝试将Unity与Prism 6一起使用,因此您必须安装的唯一软件包是Prism.Unity。这将自动引入所需的所有其他软件包:

  • Unity
  • CommonServiceLocator
  • 棱镜Wpf
    • 棱镜核心

只添加最特定的包是一种很好的做法,因为对于新的项目文件(.NET Core、ASP.NET 5、Win10 UWP),旧的packages.config文件将被project.json文件取代,NuGet v3将更好地解决依赖关系。到今天为止,它还没有用于WPF,但这不应该阻止你做"正确"的事情。

有关Prism 6的新文档和示例,请前往Prism GitHub存储库。

最新更新