Error when manually instantiating the Shell window in your bootstrapper

Sep 3, 2008 at 7:37 PM


I'm new so please be gentle ... I'm following the "Composite Application Guidance for WPF Hands-On Lab" ... 

On step 7 in the Bootstrapper section, I'm instructed to: 
"Open the file App.xaml and remove the attribute StartupUri. Because you are manually instantiating the Shell window in your bootstrapper, this attribute is not required "

When I do this, my app will launch (as I see it in the TaskManager) but, the window is not 'Shown' ....

When debugging the application, I step into the InitializeComponent() method call in my Shell.New() subroutine ... eventually arriving at the  RegionManager.OnSetRegionNameCallback method where this line of code returns a null: 


IRegionManager regionManager = element.GetValue(RegionManagerProperty)

as IRegionManager;



It seems I'm unable to get the RegionManagerProperty value .... and things go pear shaped at that point ....

This is a WPF project .... can I use with this CompositeWPF guidance?

Sep 3, 2008 at 8:19 PM
Found the problem ....

In a VB.Net WPF project (created from the Visual Studio template) ... the 'App.xaml' and related class are named 'Application' .... thus throwing off things a bit ...

This of course begs a few questions but ... for now, I'll keep plugging ...
Sep 15, 2008 at 12:14 PM
I don't exactly understand what you are doing in the InitializeComponent method.

But as far as I can see now, you should indeed get a null reference when you try to get the region manager at that point. This is because of the fact that the bootstrapper will let you create a new shell window and attach the region manager to the window at a later moment. Because the InitializeComponent method call is part of the constructor it will not yet have the region manager.

What also puzzles me is how you solved it, but I'm glad you did :)