views:

107

answers:

2

My Silverlight (4.0) app (hosted by ASP.NET website) uses 4 projects, they all use one file with assembly version:

[assembly: AssemblyVersion("1.0.*")]

The version of currently displayed application is 1.0.3842.38865, but the newer one (1.0.3854.42448) is uploaded to server recently.

The problem is that browser doesn't load new Silverlight application after it's deployment to server.

Here is a HTML-code that is used for "rendering" of silverlight-html-loader (not sure if it a correct name):

<div id="silverlightControlHost" style="height:950px"> 
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> 
  <param name="source" value="/ClientBin/VfmElitaSilverlightClientApplication.xap"/> 
  <param name="onError" value="onSilverlightError" /> 
  <param name="background" value="white" /> 
  <param name="initParams" value="adr=squad,team=811,match=3217203" /> 
  <param name="minRuntimeVersion" value="3.0.40624.0" /> 
  <param name="autoUpgrade" value="true" /> 
  <a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=3.0.40624.0" style="text-decoration:none"> 
      <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/> 
  </a> 
</object> 
<iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe> 

I've tried to add a parameter to the "source" parameter of the object that contains time of last XAP-file modification:

  <param name="source" value="/ClientBin/VfmElitaSilverlightClientApplication.xap?Ver=2010072243523AM"/>

That caused an error of Silverlight application loading:

Unhandled Error in Silverlight Application Code: 2103 Category: InitializeError Message: Invalid or malformed application: Check manifest

Could you please advise how to force browser to get new application from server (without browser cache manipulating, I would like to keep browser caching option)?

Thank you very much!

P.S. It is necessary to add that silverlight application works (uploaded and launched) fine on my localhost without any dancing with parameters. Only when I upload it to web site - it is not reloaded by browser. And adding additional parameters to the xap-file path - doesn't work on localhost.

+1  A: 

This should work as expected, maybe it has something to do with how you are appending the param. Try removing the Ver= portion:

<param name="source"
    value="/ClientBin/VfmElitaSilverlightClientApplication.xap?2010072243523AM"/> 

I have used this method in the past and it is the best way to get around any client side caching.

If you want it always to refresh and never cache you can just add the current DateTime to the end which will always be unique as well. Not sure when you would want to do this in a real world scenario but it is great for testing to ensure you never have a cached version running. Eg:

<param name="source"
    value="/ClientBin/VfmElitaSilverlightClientApplication.xap?<%= DateTime.Now.Ticks.ToString() "/>

If this isn't working, just remove it all together with no addition to the end and see if it loads. I have a feeling that the error is something else as it doesn't really apply to the location of the xap file.

Kelsey
Adding anything after ".xap" prevent application downloading and launching on the localhost, so I didn't tried to check this on the real web site.
Budda
A: 

The correct approach to managing the browsers cache is to tell it what you expect of it via the approproiate http response headers sent by the server.

In IIS manager specify that the content of the ClientBin folder be expired immediately.

Note that ths doesn't mean that the Xap wil be downloaded on every request, just that the browser should check that its cached copy is up-to-date.

AnthonyWJones