5

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?

StepUp
  • 36,391
  • 15
  • 88
  • 148
  • `Please use the new Prism.Unity package` – Jehof Nov 11 '15 at 11:10
  • @Jehof yeah, I've installed the package. However, I cannot inherits UnityBootstapper as there is no such class in Prism.Unity – StepUp Nov 11 '15 at 11:17
  • 3
    Try clean your references first, delete all reference of Microsoft.Practices.xxx and prism, then to install Prism 6, run the following command in the Package Manager Console: **PM> Install-Package Prism.Core**, and to install Unity for Prism 6 run the command : **PM>Install-Package Prism.Unity** – toumir Nov 11 '15 at 11:39
  • @Jehof, thanks! It is really dummy that I can make such mistakes). Jehof, please post your answer and I'll mark it. – StepUp Nov 11 '15 at 12:08

1 Answers1

17

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.

Bart
  • 9,925
  • 7
  • 47
  • 64
  • 1
    Thank you very much! It works! If I could upvote your answer more than once, I would do it! Million thanks:)! – StepUp Nov 12 '15 at 12:09
  • As time passes, this answer has become obsolete as well :-(. the "new" method is to use `PrismApplication` (Prism 7+) see https://stackoverflow.com/a/47910554/426315 – itsho May 26 '20 at 07:49