Monday, April 6, 2009

Silverlight 3 : Out of Browser Support – Part 6

Some people saying on various blogs and forums that this was the most awaited feature of Silverlight, well I have not contributed there because few questions came to my mind :

  • Why we need such thing when we have capability of creating WPF applications which will run on desktop/out of browser environment ??
  • How they will run? will they need Silverlight Plug-in or will they run as standard exe under windows environment? (Sorry, I said windows environment,because I don’t have Mac and Linux environment with me for testing)
  • If we process some data in Silverlight Out of Browser, will it get store in Isolated Storage? will it be sufficient storage since there is lot craze going on for Silverlight LOB applications.

Well, I started exploring at my best, Some of above are still unanswered questions for me,but I really find Out-of-Browser as an Innovation in Silverlight Technology. Since we are doing a lap around series, right now I will discuss only how to make it out of browser, once I finish this initial series, I will then take each topic in depth.

Requirements for Out of Browser Silverlight Applications :

  • Working Silverlight application.
  • sllauncher.exe file should be available.

Once your Silverlight application is ready, then to make it available out of browser, first you need to go to file “AppManifest.xml” under Properties folder.Then you will find a commented block with following message :

<!-- Uncomment the markup and update the fields below to make your application offline enabled –>

You just need to uncomment it and you are then done with it. Basically it contains :

<Deployment.ApplicationIdentity>
        <ApplicationIdentity
            ShortName="Out of Browser Silverlight Application"
            Title="My Out of Browser Silverlight Application-MVP Vikram Pendse">
            <ApplicationIdentity.Blurb>Out Of Browser Silverlight Application Created by MVP Vikram Pendse</ApplicationIdentity.Blurb>               </ApplicationIdentity>
</Deployment.ApplicationIdentity>

If you observe carefully, there is nothing “great” to understand that piece of xaml, it is pretty self-explanatory. Title attribute will show the Title on your out of browser app and <ApplicationIdentity.Blurb> will hold the description about application. So any more thing can be done with this block?..yes, a lot more can be done. You can customize the experience by adding your own icons to app,but before this, first lets talk how to launch this application out of browser. First run your application in browser, then right click on your application, you will get following context menu :

outb1

 

outb2

In era of Silverlight 2, we use to get only one option in context menu as “Silverlight Configuration” , now with the introduction of Silverlight 3 Out of browser support, we get second option as “Install..<followed by name of application>..onto this computer…”, once you click on this, you will get following message window :

outb3

Well, We have two options now, Start Menu and Desktop but have you read this message above it? as “Please confirm the locations for the shortcuts.” ,see the last word “shortcuts”, so it creates shortcuts for what and whom? Answer is :

C:\Program Files\Microsoft Silverlight\3.0.40307.0\sllauncher.exe

No, I am not saying with no base to you, if you check on Desktop a shortcut will be generated, you double click it, it will run your application as is it runs in browser, if you choose Start Menu, it will add link in Start list and both can be check too.

Well if you right click on that shortcut generated, you will get :

outb4

If you see the Target box it contains :

"C:\Program Files\Microsoft Silverlight\3.0.40307.0\sllauncher.exe" localhost.0

Comment box shows : “Allows saving your tasks offline”

[Try to change Target as “c:\” and see the effect and change in icon, Also try to delete sllauncher.exe or put it at different locations and check then if that out of browser working or not, Also try to run it on Non Silverlight environment,Try to open that offline application in Reflector etc.This will help you more to understand the architecture of this.]

Now see this install application window again :

outb3

If you see this box, you can see a Icon on left side, to customize this experience and to put your own Icon, you need to add following xaml in that uncommented block in AppManifest.xaml like this :

<ApplicationIdentity.Icons>
        <Icon Size="16x16">Images/sls16.png</Icon>
        <Icon Size="32x32">Images/sls32.png</Icon>
        <Icon Size="64x64">Images/sls64.png</Icon>
        <Icon Size="128x128">Images/sls128.png</Icon>
</ApplicationIdentity.Icons>

You can set some images to this screen of install application as well as in your title bar of actual offline application. it can be in different sizes like “16X16”,”32X32”..etc. with embedding path of that image.

So question may to come to your mind that “Can it be done programatically??” ..means can you detach this browser app to out of browser programatically?, answer is “Yes, you can!”.

If you have command button in your browser application, then you can use its click event to detach app like this :

private void Button_Click(object sender, RoutedEventArgs e)       {
          App.Current.Detach();
}

Basically App.Current.Detach(); returns a boolean, so you can check the state whether it is detached or not.

Also with App.Current.RunningOffline you can check whether application is running in browser or out of browser,since it is also returns you boolean.

If you want to remove this application, you can do so by again right clicking on application,like this :

outb5

outb6 

Well, let me make it clear that right now it is not supporting Microsoft Sync Framework, In my upcoming articles I will be talking about handling data and giving calls to services etc. so this out of browser concept will be more clear to you. I know few more things can be talked on this, but I am not doing here since we are in our lap around introductory phase and also we need to learn other features too, so do expect more stuff here in coming days.

Hope this will help you to understand Silverlight Out of Browser.

Vikram.

2 comments:

Unknown said...

Thank you Vikram.. nice Post..

I am curious to put my Out Of Browse application in Notification Area (Tray Icon). Especially when user minimizes my Out of Browser applications it should keep one ICON in Notification Area. Once he gets some alert or To-Do operation, it will show one “Notification Window” (like Outlook New Mail Notification Window). Is it possible to these kind of operations in Silverlight

thank you,
-nm reddy

Vikram Pendse said...

Hello,

Thanks for your comment.
Since the Out of Browser app which we get is shortcut to sllauncher.exe and while pulling it offline, by default we have only two options,either on Desktop or in Start Menu.

Well for notifications which you have mentioned over here, I will check the possibilities, however it is directly dependent to possibilities with sllauncher.exe,I will surely look into it and try to post.