Break up your project into smaller .xapx files using SLExtension(Silverlight Contrib)’s Bootstrapper


 

The other <a href='http://wildermuth.com/silverlight' target='_blank'>Silverlight</a> Projects

SLExtension’s Bootstrapper functionality. If you are currently using Prism or a related technology to compose your application at runtime, this functionality is lost on you. The Bootstrapper functionality is for that middle-ground where you want to break up your project into a small number of .xap files that are loaded when the project loads up but don’t need a full composition engine with MEF or Prism.

The Bootstrapper functionality is in a separately assembly in the SLExtensions project (SLExtensions.Bootstrapping.dll). This is a small assembly (so that your main project loads fast). The way it works is to have you change the derived class for the App.xaml to a BootstrapApplication:

public partial class App : BootstrapApplication
{ … }
protected override IEnumerable<Uri> Xaps
{
  get
  {
    // Must be absolute Uris so we steal it from the host
    return new Uri[] { 
      new Uri(new Uri(Host.Source.AbsoluteUri), "SecondApp.xap"),
      new Uri(new Uri(Host.Source.AbsoluteUri), "ThirdApp.xap"),
    };
  }
}
<bs:BootstrapApplication 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="FunWithBootstrapper.App"
  xmlns:bs="clr-namespace:SLExtensions.Bootstrapping;
            assembly=SLExtensions.Bootstrapping">
  <bs:BootstrapApplication.Resources>

  </bs:BootstrapApplication.Resources>
</bs:BootstrapApplication>

Shawn Wildermuth – My Favorite Silverlight Extensions APIs – Part 1

Also interesting comments:

 

Gravatar

It’s neat, but if you just want a bootstrapper I would just use the Prism bootstrapper and none of the other parts.

John Papa (Posted Monday, October 05, 2009 )

Gravatar

The problem with using Prism’s Bootstrapper alone is it requires Unity for DI and can only do loading of Modules, not .xaps (so you have to define all your .dlls and make them into modules to get them to load).

In this bootstrapper it loads the .xap file and uses the manifest to load all the assemblies.

Shawn Wildermuth (Posted Monday, October 05, 2009 )

Gravatar

The Prism bootstrapper can load xap’s as long as they use the module technique (haivng a module class file that implements the module interface). I just don’t see the effort involved in this to be an issue. While I like the open source idea here, I prefer the DI approach that Prism uses and the PnP code.

On the other hand, the cool factor is pretty high to me of the approach you show. It’s just solving a problem I already have a solution to. So for me, not so interested. But options are always good 🙂

John Papa (Posted Monday, October 05, 2009 )

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s