I was using the timestamp trick on the Silverlight
I suspect this has something to do with the builtin Cassini / Visual Studio Development server and SL5 not playing nicely together for some reason.
I'm also using the anti-cache trick you mentioned and I was experiencing the same behavior of Application.Current.InstallState always reporting NotInstalled as well as CheckAndDownloadUpdateAsync() always reporting e.UpdateAvailable = true.
So I changed my web project configuration to use IIS Express instead of the the builtin Visual Studio Development server and re-installed the Silverlight app to the desktop. Finally, everything started working as expected. In order words Application.Current.InstallState = Installed and CheckAndDownloadUpdateAsync() is reporting e.UpdatedAvailable = false.
Update:
Sorry, didn't see that you're experiencing this as well on live IIS deployments.
Update 2:
My anti-cache HTML as requested:
<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>
I have the same issue when run as OOB from Visual Studio
Regarding running from IIS remotely, I noticed that I had to edit the caching policy I had added to web.config - keeping that would always show the update/download progress logo (but would download faster than when a new version was available, only partial download maybe, but annoying to see the download progress even for a while every time)
I had to remove (comment out) the part that was trying to cache .xap till changed
<caching>
<profiles>
<add extension=".xap" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange"/>
</profiles>
</caching>
I recommend not using the DateTime approach.
Instead, append the version number to the xap url.
Edit
Sorry, just noticed you're using the LastWriteTime, which should be fine.
Try using fiddler to view the network traffic when the xap is served through IIS.
Also, show us your code that does the OOB installed check.
Edit 2
What is the default value of UpdateType? Maybe the code that checks the value of UpdateType might have run before CheckAndDownloadUpdateCompleted is called.
In regards to Application.Current.InstallState, hook into the event App.Current.InstallStateChanged.
I'm thinking maybe the default value of Application.Current.InstallState is System.Windows.InstallState.NotInstalled until the silverlight runtime has finished checking the install state, at which case it then fires the InstallStateChanged event.
When your page is loaded in your web browser, check its html source, maybe the last file write time is getting updated unexpectedly.