Auto update an OOB Silverlight application
So you created an application, have a shortcut to it on your desktop, but whenever you change it, you have to delete the link and create a new one?
This problem can be solved easily. The following code snippet does it for you:
- if (Current.IsRunningOutOfBrowser)
- Current.CheckAndDownloadUpdateCompleted += (s, e2) =>
- if (e2.UpdateAvailable)
- MessageBox.Show(“A new version was found, please restart the Application!”);
- if (e2.Error != null)
- MessageBox.Show(“There was an error updating the application!”);
* This source code was highlighted with Source Code Highlighter.
However, there are some quirks. You shouldn’t check the “Require elevated trust when running outside the browser”, because if you do so, auto update fails to start.
And another one: if you place the code above in the app constructor, it won’t work. The earliest stage I manage to get it work was the Application_Startup method.