Silverlight 3 out of browser support
It's very easy to enable the "Install onto this computer" menu for Silverlight 3, just uncomment the code in your AppManifest.xml file which is in the Properties folder of your Silverlight 3 application.
<Deployment.ApplicationIdentity>
<ApplicationIdentity
ShortName="Out of Browser Silverlight Application"
Title="Window Title of Your Silverlight Application">
<ApplicationIdentity.Blurb>Description of your Silverlight application</ApplicationIdentity.Blurb>
</ApplicationIdentity>
</Deployment.ApplicationIdentity>
This will allow users to install your application on the desktop or in the start menu.
The screen users get to install the application can also be called programatically by calling the Application.Current.Detach(); method.
How to figure out if your application is running in online mode or in detached mode?
Use the Application.Current.ExecutionState property for that. It has the following options:
- Detached
- DetachedUpdatesAvailable
- DetachedFailed
- Detaching
- RunningOnline
If a newer version is available, Silverlight will automatically download it and then set the Application..::.ExecutionState property to DetachedUpdatesAvailable, raising the ExecutionStateChanged event. This enables you to alert the user that the update is available, and will replace the previous version on the next application launch.
This sounds like click once for Silverlight, but better!
Tips for out of browser silverlight applications:
- Do not set a height and width on your main window. When the application runs out of the browser, the user can resize the window. Set width and height to "auto" or remove them.
- Set a proper Short Name to identity your application. It will be shown in the right mouse click context menu to install your application.
- Set a proper Title. This will be the Title of the window when running outside of the browser.
What about security?
When Silverlight applications run outside of the browser, will they be able to access local resources?
This is not the case. The Silverlight applications still run in the .Net Sandbox with the same security policies as in the browser.
Isolated Store when Out of Browser
When your Silverlight Application is detached (installed outside of the browser) the Isolated Store size limit is increased to 25MB.
The increased storage will also be available running your online version of the application. The online and out of browser Silverlight application uses the same isolated storage. Offline Applications still run in the context of the domain where they were downloaded from, it's still their "home".
Need more space in the Isolated Storage? It's always possible to prompt the user to allow for more space in the isolated storage.
Where are offline applications stored on the harddisk?
C:\Users<UserName>\AppData\LocalLow\Microsoft\Silverlight\Offline
How to debug Silverlight Out of Browser Applications?
Take the following steps:
- Run the application locally
- In Visual Studio go to: Debug > Attach to process
- Find the "sllauncher.exe" process which is running your Silverlight Application
- Click Attach and set your breakpoints.
- You're now able to debug your Silverlight Application which is running outside of the browser