Silverlight 5 - OOB installation / update failed while using anti-cache trick

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.

+3
silverlight-oob auto-update
Jan 23 '12 at 16:25
source share
3 answers

I suspect this has something to do with the integrated Cassini / Visual Studio Development server, and SL5 doesn't play well together for some reason.

I also use the anti-cache trick you mentioned, and I experienced the same Application.Current.InstallState behavior, always reporting NotInstalled , and also CheckAndDownloadUpdateAsync () always reports e.UpdateAvailable = true .

So, I reconfigured my web project to use IIS Express instead of the built-in Visual Studio Development server and re-installed the Silverlight application on the desktop. Finally, it all began, as expected. For the words Application.Current.InstallState = Installed and CheckAndDownloadUpdateAsync (), reports e.UpdatedAvailable = false .

Update

Sorry, I haven’t seen that you experience this too when deploying Live IIS.

Update 2 :

My HTML for caching protection on request:

 <div id="silverlightControlHost" align="center" style="height:100%"> <object data="data:application/x-silverlight-2," type="application/x-silverlight2" width="100%" height="100%"> <% string source = @"~/ClientBin/EskomVDT.SL.xap"; string param; if(System.Diagnostics.Debugger.IsAttached) { param = "<param name=\"source\" value=\"" + VirtualPathUtility.ToAbsolute(source) + "\" />"; } else { string xapPath = HttpContext.Current.Server.MapPath(source); DateTime xapCreationDate = System.IO.File.GetLastWriteTime(xapPath); param = "<param name=\"source\" value=\"" + VirtualPathUtility.ToAbsolute(source) + "?ignore=" + xapCreationDate.ToString("yyyy-MM-dd-hh-mm-ss") + "\" />"; } Response.Write(param); %> <param name="onError" value="onSilverlightError" /> <param name="background" value="white" /> <param name="minRuntimeVersion" value="5.0.61118.0" /> <param name="autoUpgrade" value="true" /> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/> </a> </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe> </div> 
+1
Apr 25 '12 at 12:17
source share

I have the same problem on startup as OOB from Visual Studio

Regarding working with IIS remotely, I noticed that I had to edit the caching policy that I added to web.config - it always displayed the update / download logo (but it would load faster than when the new version was available, maybe only a partial download but annoying to see the download process at least for a while every time)

I had to delete (comment out) the part that tried to cache .xap before changing

 <caching> <profiles> <add extension=".xap" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange"/> </profiles> </caching> 
+1
Jul 22 '13 at 10:14
source share

I recommend not using the DateTime approach.
Instead, add the version number to the xap url.

Edit
Sorry, just noticed that you are using LastWriteTime, which should be fine.

Try using a violinist to view network traffic when xap is served through IIS.

Also show us your code that sets the installed OOB check.

Edit 2

What is the default value for UpdateType? Perhaps the code that checks the UpdateType value can be run before calling CheckAndDownloadUpdateCompleted.

As for Application.Current.InstallState, connect to the App.Current.InstallStateChanged event.
I think maybe the default value for Application.Current.InstallState is System.Windows.InstallState.NotInstalled until the silverlight runtime completes checking the installation status, in which case it fires the InstallStateChanged event.

When your page loads into your web browser, check its html source, maybe the last time the file was written unexpectedly updated.

0
Feb 25 '12 at 0:00
source share



All Articles