Bootstrapper and ServiceLocator?

Topics: Bootstrappers & IoC
Jul 19, 2011 at 12:43 PM

Rob wrote in the Bootstrapper docs

While Caliburn.Micro does provide ServiceLocator functionality through the Bootstrapper’s overrides and the IoC class, you should avoid using this directly in your application code. ServiceLocator is considered by many to be an anti-pattern. Pulling from a container tends to obscure the intent of the dependent code and can make testing more complicated. In future articles I will demonstrate at least one scenario where you may be tempted to access the ServiceLocator from a ViewModel. I’ll also demonstrate some solutions.2

just wondering if the suggested follow-up was written?


what is the purpose and/or need for bootstrapper(false)?
I can see what it does, but why


Jul 19, 2011 at 12:55 PM

Bootstrapper(false) is for people who want to run Caliburn.Micro for a WPF plugin inside of a WinfForms app or from a Control library where the main application may not use Caliburn.Micro.

As an alternative to the service locator, I recommend having factory methods injected into your view models. Have a look at HelloScreens sample to see how this plays out.