Reputation: 37
im currently porting my program to using Prism 6, it's a WPF application. So i installed Prism.Unity (6.1.1) which came with Prism.Wpf (6.1.0), Prism.Core (6.1.0), Unity (4.0.1) and CommonServiceLocator (1.3.0).
Then i came along those PRISM samples, but for the love of god i can't get it to run. Here's my Bootstrapper:
public class Bootstrapper : Prism.Unity.UnityBootstrapper
{
/// <exception cref="ActivationException">If there are errors resolving the shell instance.</exception>
protected override DependencyObject CreateShell()
{
return Container.Resolve<Shell>();
}
protected override void InitializeShell()
{
base.InitializeShell();
Application.Current.MainWindow = (Window)this.Shell;
Application.Current.MainWindow.Show();
}
protected override void ConfigureContainer()
{
base.ConfigureContainer();
this.RegisterTypeIfMissing(typeof(IWorkRepository), typeof(WorkRepository), true);
}
}
Unfortunately i can't start it. VS 2015 says it needs System.Runtime to run
return Container.Resolve<Shell>();
but once added the whole class is marked as error. If i start it directly i get the exception it couldn't load Microsoft.Practices.ServiceLocation. I'm wondering of the dependency since several posts (including ms) suggests to remove all Practices.*.
Help would be really appreciated, since i can't get it to run. :(
Upvotes: 1
Views: 4419
Reputation: 10873
What using
s do you use?
The whole bootstrapper can be as simple as this (created by the Prism-template):
using Microsoft.Practices.Unity;
using Prism.Unity;
using PrismUnityApp2.Views;
using System.Windows;
namespace PrismUnityApp2
{
class Bootstrapper : UnityBootstrapper
{
protected override DependencyObject CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void InitializeShell()
{
Application.Current.MainWindow.Show();
}
}
}
and System.Runtime
isn't needed as reference. Probably you inadvertently use a namespace from that (instead of Microsoft.Practices.Unity
where the Container.Resolve<>
extension is).
Upvotes: 1