Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I create instead of Bootstrapper? Prism 6.1.0

Tags:

c#

mvvm

wpf

xaml

prism

I've tried to update my application from Prism v4.0 to Prism v6.1.0 and run package manager: PM> Install-Package Prism.Core

and PM has installed such 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've tried to create bootstrapper:

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've tried to resolve the UnityBootstrapper. However, there is no such a class at Prism 6.1.0. So I've tried to install by Nuget:

Prism.UnityExtesions

However NuGet says: 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.

So to my mind come the question: How to create bootstrapper at Prism 6.1.0?

like image 445
StepUp Avatar asked Nov 11 '15 11:11

StepUp


1 Answers

As mentioned in the comments by @toumir, first uninstall all Microsoft.Practices.* packages (check your packages.config to be sure they're all uninstalled).

Since you're trying to use Unity with Prism 6, the only package you have to install is Prism.Unity. This will automatically bring in all other packages needed:

  • Unity
  • CommonServiceLocator
  • Prism.Wpf
    • Prism.Core

It's a good practice to only add the most specific package, as with the new project files (.NET Core, ASP.NET 5, Win10 UWP) the old packages.config file is replaced by a project.json file and NuGet v3 will take care of better dependency resolving. As of today it's not used yet for WPF, but that shouldn't keep you from doing it "right".

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

like image 57
Bart Avatar answered Oct 26 '22 17:10

Bart