Using caliburn in VSTO apps

Jul 7, 2010 at 3:21 PM
I am hosting wpf user controls in vsto apps within an ElementHost. The problem I am having is when manually instantiating the bootstrapper in the ShellViewModel code behind I get a nullreferenceexceptions when accessing the Application object. This make sense as the wpf Application doe snot exist in this scenario. Any other way I can get this working? Thanks Nabil public static void InitializeWithDispatcher() { #if SILVERLIGHT var dispatcher = Deployment.Current.Dispatcher; #else var dispatcher = Application.Current.Dispatcher; #endif executor = action =>{ if(dispatcher.CheckAccess()) action(); else dispatcher.BeginInvoke(action); }; }
Coordinator
Jul 7, 2010 at 3:45 PM
I'll investigate.
Coordinator
Jul 8, 2010 at 3:34 PM

I fixed an issue related to the Dispatcher class, so I believe it should work in your scenario. However, you do not want to use the bootstrapper, because that relies on the existence of Application. You will need to configure the framework manually, which isn't difficult. Wherever your startup code is, you'll need to add this:

Execute.InitializeWithDispatcher();
AssemblySource.Instance.AddRange(assembliesContainingYourViews);
//Required if using an IoC container.
IoC.GetInstance = aMethodThatProvidesThisForYourContainer;
IoC.GetAllInstances = aMethodThatProvidesThisForYourContainer;
IoC.BuildUp = aMethodThatProvidesThisForYourContainer;