Deploy your equipment locally and globally

Silverlight Out of Browser (OOB) Versions, Images, and Isolated Storage

This is a quick and simple post to address three very common questions I receive about Silverlight Out-of-Browser (OOB) applications. In case you haven’t heard, applications made with Silverlight version 3 and later can be installed locally to your machine (whether it is a Windows machine or a Mac) and run “out of the browser” as a local application. In Silverlight 4, you can also run with partial trust. That is not the focus on this post.

Creating an out of browser application is quite easy. Open the project properties for your Silverlight application. You will find a checkbox that allows for installation when out of browser:

Silverlight Out of Browser

Simply check the box and you are on your way! Of course, you can also click the button to set other properties, such as the name and description for the application, provide icons for installation, and decide whether you want it to run with elevated trust.

<

p style=”font-size:1.2em”>Question One: How do I publish new versions of my Silverlight Out-of-Browser Application?

This is easy. Silverlight does not do version checking by itself. To Silverlight, your “version” is basically the Uri of the XAP file from which it was originally downloaded. If you publish a new XAP file for the web version, when the user revisits, it automatically pulls down the newest version (sometimes this doesn’t happen immediately because the XAP file may be cached by the browser, similar to images and other resources). The out of browser application is the same: when the application starts, it automatically polls the server. If a new XAP file is detected, the bits are downloaded and the application is updated.

Of course, this sort of “forces” the update out of the box. Jeff Wilcox’s blog has an excellent article about Out of Browser that demonstrates how to handle the update experience programmatically by prompting the user.

<

p style=”font-size:1.2em”>Question Two: Do I need to embed my images for out-of-browser to work?

The answer is “no.” Out-of-browser works very similar to “in the browser.” Images can fatten XAP files so most people place the images in the ClientBin folder where the XAP file resides. This allows you to reference the image with a relative path:

...
<image source="foo.jpg"/>
...

If foo.jpg is located in the root of ClientBin on the server, it will load just fine. But what about with OOB? The same thing happens. The installed application retains a pointer to the Uri where it was installed from (this is how it can check for new versions). When a relative image reference is found, it will simply download it relative to the XAP file directory, the same as the online application. Therefore, you do not have to package the images in the XAP for them to become available.

But what about when the application is offline?

This is tricky territory. The word on the street is that it will still use your browser’s cache to retrieve the images. This makes it very unpredictable, because you never know when the cache will clear and in my tests, you’ll often end up with an application that has no images. If you are writing an application that spends a good deal of time in offline mode, you will probably want to embed your images in the XAP to make sure they are available all of the time.

<

p style=”font-size:1.2em”>Question Three: Do the web and desktop versions of my application share the same isolated storage?

Yes, they do.

This one may seem confusing because the default size of isolated storage for a web application is 1 megabyte (MB) while the default for out-of-browser applications is 25 megabytes. However, despite the difference in quota, both versions point to the same isolated storage location.

The Example

To illustrate the image and isolated storage points, I made a very simple out of browser application that you can play with here. It contains an image file that is external to the XAP, so you can see how it is fetched the same way both in and out of browser. It also automatically detects the mode it is running in. In the web browser mode, you can enter text and click a “serialize” button to write that text to isolated storage. In the OOB mode, it has a “deserialize” button that reads from isolated storage and writes into the text box. You can run the web and out of browser versions at the same time, serializing data from the web version and immediately deserializing it from the OOB version to see how they share the same isolated storage.

Run this application in a separate window.

To install the application to your desktop, simply right-click and select the option to install:

Installing an OOB application

The code for this is simple. Note that I did not do any error checking, so you’ll want to serialize some text before attempting to deserialize it. This is the code behind for the application:

public partial class MainPage
{
    private const string FILE = "testserialization.txt";
        
    public MainPage()
    {
        InitializeComponent();
        Application.Current.InstallStateChanged += Current_InstallStateChanged;
        ISOButton.Content = Application.Current.IsRunningOutOfBrowser ? "Deserialize" : "Serialize";
    }

    void Current_InstallStateChanged(object sender, System.EventArgs e)
    {
        ISOButton.Content = Application.Current.IsRunningOutOfBrowser ? "Deserialize" : "Serialize";
    }

    private void IsoButtonClick(object sender, RoutedEventArgs e)
    {
        if (Application.Current.IsRunningOutOfBrowser)
        {
            using (var iso = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (iso.FileExists(FILE))
                {
                    using (var br = new BinaryReader(iso.OpenFile(FILE, FileMode.Open, FileAccess.Read)))
                    {
                        Text.Text = br.ReadString();
                    }
                }
            }
        }
        else
        {
            using (var iso = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (var bw = new BinaryWriter(iso.OpenFile(FILE, FileMode.Create, FileAccess.Write)))
                {
                    bw.Write(Text.Text);
                }
            }
            Text.Text = "--- wrote to iso ---";
        }
    }
}

Notice that the content and behavior of the button changes based on whether or not the application is running out of browser (OOB). It also hooks into the InstallStateChanged event to update “on the fly” when the user installs.

Hopefully this short post demonstrates some useful concepts about running your applications out of browser. You can download the source for the example here.

Jeremy Likness

Improve
system uptime.

Decrease
resolution times.

Rely on proven
data centers.

Plan a path
to the cloud.

Together we will reduce the potential for business impacting outages by leveraging modern and secure data centers.

Confidently take advantage of a highly trained 24x7x365 team of professionals who can perform remote hands services.

We deliver environments that are SSAE Type II audited by a third party and N+1.

We can help you migrate to a public, private or combination cloud using our deep knowledge and real world experience.

Visit our award winning data centers.

Schedule a Tour

Enterprise-Grade Colocation

Atmosera owns and operates secure data centers for customers that need full-service space, power and cooling. We offer secure racks, cabinets and cages, and network connectivity from multiple network providers.

3

1

21,000+

Locations in Portland, OR

Location in Phoenix, AZ

Square Feet in Portland, OR

Atmosera owns three flagship data centers in the Portland, Oregon metropolitan area and operates a Disaster Recovery (DR) site in Phoenix, Arizona.

  • Data Center

    Address

  • Beaverton, OR

    9610 SW Sunshine Ct

  • Beaverton, OR

    9705 SW Sunshine Ct

  • Data Center

    Address

  • Phoenix, AZ

    615 N 48th St

  • Portland, OR

    511 SW 10th Ave

Reliable, Secure, Audited

All Atmosera operated data centers are SSAE 16 Type II, audited by a third party and offer 24x7x365 secure access with two-factor authentication, and individually keyed cabinets and cages. Atmosera’s Technical Assistance Command Center (TACC) provides around the clock monitoring and remote hands service for customers who need it.

Cloud Migration Path

From colocation to cloud is easier than you might think. Many Atmosera customers have enlisted our help to migrate into the cloud from their existing colocation deployments. Some customers are also maintaining their colocation while deploying new applications in a private or public cloud and running a true hybrid deployment. Regardless of where you are in your cloud journey, Atmosera can help you with your colocation and any cloud migrations to meet your business needs.


Managed Colocation Services

To meet every customer’s requirements, we offer the following:

  • Racks, full cabinets or secure cages
  • Network connectivity from multiple service providers
  • Fully managed network infrastructure
  • Multiple hardened layers of security, reliability and protection
  • Rigorous operations and maintenance procedures
  • 24x7x365 secure access with two-factor authentication, and individually keyed cabinets and cages

24x7x365 Support

Professional services and fully managed deployment options include:

  • Faster remediation via remote hands and ongoing assistance
  • Architecture, design, procurement and installation services
  • 24x7x365 monitoring of services and equipment
  • Managed security
  • Data protection and backup

Other services you may find interesting:

Explore Our Resources

Download Data Sheets, Case Studies and Infographics.
View our Videos featuring demos and customer insights.

View Resources

We deliver solutions that accelerate the value of Azure.

Ready to experience the full power of Microsoft Azure?

Start Today

Blog Home

Stay Connected

Upcoming Events

All Events