Silverlight 3: Taking an application offline

One of the exciting new features of Silverlight 3 is the ability to take an application offline. In order to take advantage of this feature you must do three things:

  1. Establish Application’s Offline Identity.
  2. Detach the application.
  3. Handle when running offline.

Step 1: Establish Application’s Offline Identity

The application’s offline identity is defined in a file called AppManifest.xml that lives in the Properties folder of any standard Silverlight Application project. Within this file you can do a number of things, such as specify icons and other dependent packages or assemblies.

<Deployment.Parts>
</Deployment.Parts>

 
<Deployment.ApplicationIdentity>
    <ApplicationIdentity 
        ShortName="Hello World!" 
        Title="Offline Hello World!">
        <ApplicationIdentity.Blurb>
          This application greets the world with gleeful exuberance.
        </ApplicationIdentity.Blurb>
    </ApplicationIdentity>
</Deployment.ApplicationIdentity>

 

Step 2: Detach the application

The Application object exposes a new method called Detach to initiate the process of sending an application offline.

App.Current.Detach();

 

02

It’s important to make sure that you determine whether the application has already been detached because if it has then calling this method will only result in an Invalid Operation Exception. However, if it happens to be the first time the user has taken this application offline they will immediately be greeted by the prompt below asking them if they truly want to install the application onto their computer.

03 04

After an application has been taken offline. You can right click anywhere inside of it and select “Remove this application”.

0501

 

Step 3: Handle when running offline

The Application object exposes two new properties that allow you to check whether the application has ever been detached and whether the current instance of the application is an offline version.

Execution State defaults to RunningOnline. After an application has been detached, however, it changes to Detached.

App.Current.ExecutionState

The running Offline flag is false when the user opens the application through the browser; likewise, it is true when the user opens the application from the Desktop or Start Menu short cuts that were created.

App.Current.RunningOffline

One thought on “Silverlight 3: Taking an application offline

  1. I think you mean, running a Silverlight application out of browser, not offline. A Silverlight application can run both online and offline and both in and out of the browser.

    Like

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