I used the timestamp trick on Silverlight <object> (see GetLastWriteTime() with answers How do I get Firefox to not cache or reload a Silverlight XAP file? ) Using Silverlight 4.
Using Silverlight 5 runtime * , the OOB install / auto-update function now seems to be broken. I have two questions:
- when launched in the browser, the current installation state is always "not set" (in the code:
Application.Current.InstallState == System.Windows.InstallState.NotInstalled always true ) - when starting in OOB mode, it always says that a new version is available (in the code:
CheckAndDownloadUpdateAsync() always returns with e.Error == null and e.UpdateAvailable == true ).
Has anyone else come across this, and even better, has a workaround?
* Accuracy: My application is currently built using Silverlight 5 Tools, but targets Silverlight 4 and works fine on Silverlight 4 Developer Runtime. The problem arises (at least) with my dev machine using Silverlight 5 Developer Runtime.
Update: I checked with Fiddler what was going on in my dev block. When the update process is called, I see:
GET /ClientBin/Client.xap?timestamp=23%2f01%2f2012+17%3a42%3a14 HTTP/1.1 If-Modified-Since: Tue, 24 Jan 2012 09:10:07 GMT
This is good for me, except that the server (Server: ASP.NET Development Server / 10.0.0.0, X-AspNet-Version: 4.0.30319) returns a new version with the following cache headers:
HTTP/1.1 200 OK Cache-Control: private Date: Tue, 24 Jan 2012 09:11:28 GMT
Each time I run the application, the validation request has the correct date (previously returned by the server), and each time the server says that it has a new version with the current date. I will try to configure the server configuration.
Update2: I had a cache management directive in my Web.config file, but deleting it only solved half the problem. Now the application in the browser detects that the OOB installation is OK, but the update cycle continues with the same Fiddler trace.
Update3: The problem is definitely related to the debug web server. The same application installed for proper IIS with the same Web.config does not have this problem. But this is still annoying, as it significantly slows down the OOB debugging process.
Update4: Actually, the problem is still present even in my main IIS deployment and has occurred on other servers (and using PHP to generate a timestamp instead of ASP.NET). Therefore any help is appreciated.
Update5: As requested, here is my code, quite simple:
private void CheckAndDownloadUpdateCompleted(object sender, System.Windows.CheckAndDownloadUpdateCompletedEventArgs e) { if (e.Error != null) { if (e.Error is PlatformNotSupportedException) { UpdateType = UpdateTypes.PlatformUpdate; //(...) return; } else if (e.Error is SecurityException) { UpdateType = UpdateTypes.ElevationRequired; //(...) return; } else { // Error handling code //(...) } } else if (e.UpdateAvailable) { UpdateType = UpdateTypes.Available; //(...) return; } UpdateType = UpdateTypes.NoUpdate; //(...) }
UpdateType is an enumeration type property that allows me to select the desired localized string somewhere else.
Update6: The various parts //(...) (indirectly) change the presentation of the application, UpdateType not.