I was using the timestamp trick on the Silverlight <object> (see GetLastWriteTime()
using answers in How do you force Firefox to not cache or re-download a Silverlight XAP file?) successfully with Silverlight 4.
Using a Silverlight 5 runtime*, the OOB install/auto-update feature now seems broken. I have two issues:
- when launching in browser, the current install state is always 'not installed' (in code:
Application.Current.InstallState == System.Windows.InstallState.NotInstalled
is alwaystrue
) - when launching in OOB mode, it's always saying that a new version is available (in code:
CheckAndDownloadUpdateAsync()
always returns withe.Error == null
ande.UpdateAvailable == true
).
Has anyone else encountered this, and better yet, has a workaround?
* Precision: currently my app is built using the Silverlight 5 Tools, but is targeting Silverlight 4, and works fine on a Silverlight 4 Developer Runtime. The problem occurs on (at least) my dev machine using the Silverlight 5 Developer Runtime.
Update: I've checked with Fiddler what happens on my dev box. When the update process is invoked, 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
That's fine 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 app, the check request has the right date (the one previously returned by the server), and each time, the server says it has a new version, with the current date. I will try to tweak the server config.
Update2: I had a cache control directive in my Web.config file, but removing it only solved half the problem. Now the in browser app detects that the OOB install 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 deployed to a proper IIS with the same Web.config doesn't have this issue. But this is still annoying, as it considerably slows down my OOB debug process.
Update4: In fact, the problem is still present even on my main IIS deployment, and has happened on other servers too (and using PHP to generate the timestamp instead of ASP.NET). So any help is appreciated.
Update5: As requested, here is my code, fairly straightforward:
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 enum type property that allow me to pick the right localized string somewhere else.
Update6: The various //(...)
parts are (indirectly) changing the view of the application, UpdateType
is not.