What should I create instead of Bootstrapper? Prism 6.1.0

I tried updating my application from Prism v4.0 to Prism v6.1.0 and starting the package manager: PM> Install-Package Prism.Core

and PM installed the following packages:

  • 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

The next step I tried to create bootstrapper is:

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; } } 

and I tried to enable UnityBootstrapper . However, in Prism 6.1.0 there is no such class. So I tried installing Nuget:

 Prism.UnityExtesions 

However, NuGet says: This package is no longer supported. Please use the new Prism.Unity package This package is no longer supported. Please use the new Prism.Unity package .

There is a bootstrapper class with Prism 5.0. But Prism 5.0 is not supported now. For example, in this example, HelloWorld from code.msdn.

Therefore, in my opinion, the question arises: How to create a bootloader in Prism 6.1.0?

+5
source share
1 answer

As mentioned in the comments of @toumir, first uninstall all Microsoft.Practices.* Packages (check your .config package to make sure that they are all removed).

Since you are trying to use Unity with Prism 6, the only package you need to install is Prism.Unity . This will automatically add all the necessary packages:

  • Unity
  • CommonServiceLocator
  • Prism.wpf
    • Prism.Core

It’s good practice to add only the most specific package, as in new project files (.NET Core, ASP.NET 5, Win10 UWP), the old package.config file is replaced by the project.json file and NuGet v3 will take care of improving dependency resolution . To date, it has not yet been used for WPF, but this should not prevent you from doing this "correctly."

For the new documentation and samples on Prism 6, please go to the Prism GitHub repositories.

+17
source

Source: https://habr.com/ru/post/1235686/


All Articles