Migrating to V4 - BootStrapper Error

Topics: Prism v4 - Silverlight 4
Feb 3, 2011 at 6:50 PM

Hi,

We have just migrated our solution to Prism V4, and we have a strange error in bootstrapper.

In our Shell Module, we have reference for Microsoft.Pratices.Prism, Microsoft.Pratices.Prism.UnityExtensions and Microsoft.Pratices.Unity.Silverlight.

Here is the bootstrapper. It was ok before.

public partial class BootStrapper : UnityBootstrapper
{
     protected ShellView ShellView { get; set; }

protected override void ConfigureContainer()
{
     base.ConfigureContainer();
}

protected override RegionAdapterMappings  ConfigureRegionAdapterMappings()
{
     RegionAdapterMappings mappings = base.ConfigureRegionAdapterMappings();
     mappings.RegisterMapping(typeof(Grid), Container.Resolve<GridRegionAdapter>());
     return mappings;
}
        
protected override DependencyObject CreateShell()
{
     ShellView = Container.Resolve<ShellView>();
     App.Current.RootVisual = ShellView;
     return ShellView;
}

protected override IModuleCatalog CreateModuleCatalog()
{
     GlobalHelper.Container = Container;
     return Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml(new Uri("/Company.CommonModules.Shell;component/ModulesCatalog.xaml"));
        }
        
protected override void InitializeModules()
{
     base.InitializeModules();

     Container.RegisterType<IShellViewModel, ShellViewModel>();
     IShellViewModel shellViewModel = Container.Resolve<IShellViewModel>();
     ShellView.DataContext = shellViewModel;
}
}
The errors are in red : Methods ... Does not have type pearameters
Error 2 The non-generic method 'Microsoft.Practices.Unity.IUnityContainer.Resolve(System.Type, string, params Microsoft.Practices.Unity.ResolverOverride[])' cannot be used with type arguments.
In all our modules, we are able to use Container.RegisterType and Container.resolve
In the IModule class
Container.RegisterType<IViewModel1, ViewModel1>();

In another class
ViewModel = container.Resolve<IViewModel1>();
View = container.Resolve<View1>();
View.DataContext = ViewModel;
We can't figure out why we have this problem.
Could you help us. Thnks.
Chris
Feb 3, 2011 at 8:20 PM

Hi Chris,

This error might be caused because you are missing the line: “using Microsoft.Practices.Unity;” in the Bootstrapper class.

The Resolve method is an extension method, that can't be found unless you add this using line to your class. You could check this issue in the following work item.

Additionally, you can read Appendix D: Upgrading from Previous Versions

Please, let me know if this information helps you.

Thanks,

Miguel Bronzovic
http://blogs.southworks.net/mbronzovic

Feb 3, 2011 at 9:31 PM

Hi Miguel,

Thank you for you answer.

You were right, we were missing this "using". It works now.

The appendix D, was also really helpful to manage our migration.

 

Thanks again,

Chris