Friday, July 24, 2009

Silverlight 3 : Out Of Browser

I have already written an article over Silverlight Out Of Browser functionality few months back (http://pendsevikram.blogspot.com/2009/04/silverlight-3-out-of-browser-support.html) , Now I am rewriting it due to some Breaking Changes from Beta to RTW of Silverlight 3. The working principle and the architecture remains same as it was in Beta, but way of execution is bit different for RTW. Do read my previous article to find out more on sllauncher.exe file, now in RTW you can see this sitting outside framework folder like this :

OOB

With Silverlight 3 RTW, now you don’t need to put configuration inside “AppManifest.xaml” , you have a full fledge wizard to handle those settings which you can find inside Project Properties option like this :

OOBSettings_thumb[7]

Here you can find all settings including Icons, you can browse those, you can set Width and Height along with title. Some of my enthusiast friends wend ahead and try to did this config by means of old way in AppManifest.xaml, At first hit of F5 they told me that look it runs without any compile error ! so it can be done ! ..but after few seconds, nothing was happen and then I shown them in status bar that we have error nicely put forth like this :

ErrorAppIdentity

Now let’s talk about doing this via code, previously it was :

App.Current.Detach(); now it is replaced by App.Current.Install

You also have one boolean property as InstallState which gets the current installation state of the application. As far as network capabilities are concern NetworkChange.NetworkAddressChanged event and NetworkInterface.GetIsNetworkAvailable() are intact to monitor network connectivity of application.

Code snippet like following will help you to understand which mode application is in currently :

if (App.Current.IsRunningOutOfBrowser)
            {
                Reftext.Text = "Out of Browser";
            }
            else
            {
                Reftext.Text = "In Browser";
            }

Rest of the things as far as working principles are concern are same as it was in Beta environment.

Some point I would like you to focus on while developing this kind of OOB apps.

1. I encourage you to read more on ShowInstallMenuItem="False" which is an attribute inside OutOfBrowser.xml file which you can see inside your project. Find out in documentation, what this is capable of doing.

2. Read more on Application.CheckAndDownloadUpdatesAsync() along with its corresponding event handler CheckAndDownloadUpdatesCompleted and what capabilities they own. These two might be key terms who will play a vital role in your OOB Silverlight apps.

For the last point (2nd), I encourage you to visit Ashish Shetty’s blog who is part of SL Team and he wrote very good articles especially on OOB functionality, He covers all aspects from Developers as well as from Architectural point of view, Here is URL :

http://nerddawg.blogspot.com/2009/07/silverlight-out-of-browser-apps-how.html

I will very soon talking about other breaking changes while you migrate from Beta to RTW, I hope this will help you and reduce your migration pain, will talk on other things soon.

Vikram.

No comments: