We have an Out Of Browser app. We have a call to force the user to download the latest version of the app and then exit out if a new version is available. This used to work fine, but for some reason, recently it hasn't been working.
My question is - what criteria does Silverlight use to figure out if the Xap package has changed? How can I force it to download the latest?
I would have though that this would be a simple matter of checking the date on the Xap package to see if it has changed or not. Is there any way to make the Xap package update based on the date/time stamp of the Xap package file?
I had the same problem. Reading the docs it says if your application requires elevated trust the automatic update won't work unless you sign it. Thats why it works from visual studio but not when you put it on the server.
Sample code to Update your XAP File
add below two line in your App_Startup
this.CheckAndDownloadUpdateCompleted += new CheckAndDownloadUpdateCompletedEventHandler(App_CheckAndDownloadUpdateCompleted);
void App_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
MessageBox.Show("Update received, please restart");
MessageBox.Show("NO update received!!!");
also if e.UpdateAvailable == false and e.Error is
a) a PlatformNotSupported-Exception, then an Update is available requires a new Silverlight-version, or
b) a SecurityException, then security has changed and you have to inform user to visit the HTML-based Silverlight upgrade...
OK. Sorry to get back to everyone on this one. I can now tell you more about the problem. I can tell you that Required Elevated trust is turned off for both In Browser and out of Browser. I can also tell you that when the app tries to update, the error message I get is:
System.PlatformNotSupportedException: Operation is not supported on this platform.
Acording to Microsoft:
If an application update is available, but uses a newer version of Silverlight that the user has not yet installed, the update will not be downloaded. [...]. In both cases, the UpdateAvailable property value is false, and the Error property value is an Exception instance. With a Silverlight version change, the exception is a PlatformNotSupportedException instance.
So, theoretically, it's saying that the version I'm trying to install requires a higher version of Silverlight than I have installed which is rubbish. How could I compile a Xap package for a runtime environment higher than my own? The AppManifest's runtime version is
And my installed version is
So, what's its problem?
Also, a big WTF? on the error when elevated trust is required. That doesn't make any sense at all!!!!
If I'm a user who downloads an app and that app wants to install a new version of itself, I should at least have an option not to do so. Why the F@#$ am I not allowed to decide if an app can update itself or not?
Silverlight should throw up one of those ugly message boxes to ask me if I'm sure I want to let the app update itself.
is there the "InBrowser"-settings in the XAP?? If yes, then the following bug might be the problem -> Silverlight 5 RTM OOB apps won't update Platform Not Supported
Check if any inbrowser-settings are in the AppManifest.xaml, if yes... remove them (remove InBrowserSettings.xml from properties-folder)... and try again...
maybe it helps...
It turns out that removing the section does solve the problem. This is god damned annoying.
We want to enable elevated trust on all parts of our app, but the app won't update if any of these settings exist. What the hell are Microsoft doing?
At the very least, the user should get the option as to whether or not they want to update the version. It shouldn't just stop them from updating outright if the app requires elevated trust.
WTF? Why was the above comment marked as the answer?
Anyway, in the end we were forced to sign up for a real certificate and sign our xap package with the certificate. We now have elevated trust on the app and updates work correctly.
Still, it shouldn't be necessary to do this. I still say this is a bug in Silverlight.