Countdown to Silverlight 3 #1: Out of Browser applications

by Andrej Tozon 26. June 2009 01:48

With Silverlight 3 knocking on the door (July 10?) it’s time to offload my Silverlight 3 examples. Not that they would show anything new (since SL3 Beta got out, new features had been demoed by various people to the death), it’s just another perspective or a way to go public with a sample code that’s been piling up on my desktop since the Beta was released. Anyway, this will be in a form of short posts with provided test page and sample code.

I’ll begin with probably the most talked about new feature – Out of Browser applications, which could also be referred to as installed applications.

First of – not every Silverlight application can be installed on the client machine. The developer must enable this by adding a <Deployment.Application> section to the application manifest (AppManifest.xml). This section provides more information about the application (name, title, description), along with optional icons in a few different sizes, which are used for branding your application and are displayed on various places on the desktop (install dialog, application shortcut, title bar, …)

Alternative way to installing the application (a common way is to install it through the Silverlight application right-click context menu) is to provide the user with a button of some sort, which would call the new Application.Current.Detach() method when clicked. Note that the method requires an explicit user action to succeed; calling it on the application load or perhaps inside a timer tick event should fail with the exception.

There’s the Application.Current.ExecutionState property telling the installation state of the application. Possible values include RunningOnline (not installed, the default), Detaching, Detached, DetachedUpdatesAvailable and DetachFailed (for describing various installed/ing states).

When installed, the application can be run as before, inside the browser, or, by calling it through a created shortcut (start menu, desktop), outside the browser. Inspecting the Application.Current.RunningOffline property will tell you how the application was run.

To check if application is connected to the network, there’s the NetworkInterface.GetIsNetworkAvailable() method, returning a simple true or false. Remember that being connected to the network doesn’t mean application has access to the internet, and certainly doesn’t imply that a network resource or a service application wants to call is accessible at all.

One last thing to mention is that Out of Browser application still run in a partial trust, the same security context as it would when run inside the browser. The isolated storage quota, however, increases to 25MB when application gets installed.

Additional reading
http://timheuer.com/blog/archive/2009/03/18/silverlight-3-offline-update-framework.aspx
http://msdn.microsoft.com/en-us/magazine/dd882515.aspx

Run the sample online

Source code below:

Tags:

Silverlight | Development

Comments

6/27/2009 12:49:13 AM #

Nicholas Bedworth

Any ideas on hacks that woulld make the browser frame around the OOB window disappear? In other words, we'd like the SL OOB material to appear to float over the desktop, no signs that there's a browser involved. I believe this can be done, can't quite locate the reference at the moment.

Nicholas Bedworth United States | Reply

6/28/2009 7:13:06 AM #

Andrej Tozon

Nicholas,
I'm not aware of any hacks that would make this possible. Currently (SL3 Beta) there is no way you can change the window chrome or even control the size of the window. This is mainly due to protecting the user from running a malicious content. We're yet to see if Silverlight 3 RTW changes this in any way.

Andrej Tozon Slovenia | Reply

6/29/2009 9:54:07 PM #

Alex Golesh

Andrej,

Nice post!
I have some very small comments though: first of all it should be not "July 10?", but "July 10!" Smile Yes, SL3 will be released at this date.
Second, the APIs you are talking about in the post (<Deployment.Application>, Application.Current.Detach(), Detaching, Detached, DetachedUpdatesAvailable, etc.) was changed in RTW. Smile
Last but not least - just for Nicholas: no, it is still not possible to customize chrome of the OOB window Frown

Regards,
Alex

Alex Golesh Israel | Reply

6/30/2009 10:50:29 PM #

Nicholas Bedworth

Alex, Andrej et al., Thanks for everyone's comments... at least this lack of chrome customization is a well-known request that is being evaluated for SL4. Definitely not for SL3. So we'll just keep feeding in use cases that show off the virtues of chrome customization and that will help.

Nicholas Bedworth United States | Reply

7/2/2009 6:39:26 PM #

Nicholas Bedworth

BTW in case anyone was wondering, the avatar doesn't look at all like me Smile

Now, another OOB "gotcha" is that apparently this model doesn't allow JavaScript. Ooops. Another rewrite, but fortunately not major.

Any Mesh Maniacs around? I'm working if the Silverlight app is launched as a Mesh object whether the JavaScript issue would still obtain? Presumably "yes" in that both platforms target the Core CLR, but one never knows.

And we have some exotic Mesh scenarios if anyone would like to contact me off list.

Nicholas Bedworth United States | Reply

7/4/2009 9:05:16 AM #

Andrej

Nicholas, when running OOB, you can't access page's HTML (DOM), therefore no JavaScript is available.

Andrej Slovenia | Reply

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading





Andrej Tozon
Andrej Tozon's on Twitter View Andrej Tozon's profile on LinkedIn Subscribe to me on FriendFeed Andrej Tozon's Facebook profile

MVP - Client Application Developer

Microsoft Certified Solution Developer

MSN Alerts

Get help from Andrej Tozon!

 

Currently reading


Microsoft Silverlight 4 Data and Services Cookbook

Stay tuned for the review... In the mean time, you can read an excerpt from the book.

RecentComments

Comment RSS