RegionManager fails when launched from WinForm

Topics: Prism v2 - WPF 3.5
Apr 27, 2009 at 4:31 AM

I have a solution built on v1 and everything works fine. After upgrading to v2, it fails in the following scenario, a WinForm project launches the Bootstrapper in the Shell project. All region definitions seem to be missing thus the region collection is always empty. Thus no view can be added to the shell. The same Shell project works fine if it's launched directly as a WPF application. Please help, thanks.

Apr 28, 2009 at 10:28 PM

Hi Daniel,


I was able to reproduce the error you mention.  With a bit of debugging I realized the issue that was causing region not to be created was the IsInDesignMode() method from the RegionManager class which needs the Application.Current to be set.


The right way of launching the Shell is though the Application as follows:



That way the Bootstrapper is also ran and the Application.Current will be set correctly. You will need to add references to the WindowsBase and PresentationFramework assemblies in your WinForm launcher project.


Hope it helps!


Matias Bonaventura