Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 更新后强制浏览器重新加载Silverlight xap_C#_Silverlight_Deployment_Caching_Xap - Fatal编程技术网

C# 更新后强制浏览器重新加载Silverlight xap

C# 更新后强制浏览器重新加载Silverlight xap,c#,silverlight,deployment,caching,xap,C#,Silverlight,Deployment,Caching,Xap,我有一个Silverlight控件打包并部署到SharePoint web部件。推送更新后,浏览器加载控件的新版本时遇到问题。我正在更新我的xap项目的程序集和文件版本,但这似乎无关紧要。让浏览器加载新xap的唯一方法是进入并删除Internet临时文件。对我来说,在开发过程中,这是可以的,但我需要在生产之前找到一个解决方案。有什么想法吗?这与浏览器处理资源请求的方式有关。Flash也有类似的问题,有两种解决方法 下面是一个详细说明问题和可能的解决方案的示例 我建议你这样做: 假设您在html中

我有一个Silverlight控件打包并部署到SharePoint web部件。推送更新后,浏览器加载控件的新版本时遇到问题。我正在更新我的xap项目的程序集和文件版本,但这似乎无关紧要。让浏览器加载新xap的唯一方法是进入并删除Internet临时文件。对我来说,在开发过程中,这是可以的,但我需要在生产之前找到一个解决方案。有什么想法吗?

这与浏览器处理资源请求的方式有关。Flash也有类似的问题,有两种解决方法

下面是一个详细说明问题和可能的解决方案的示例

我建议你这样做:

假设您在html中为xap设置了以下内容:

<param name="source" value="ClientBin/myApp.xap"/>

我会对它进行版本设置,这样每当你推送时,你就可以更改版本号。例如:

<param name="source" value="ClientBin/myApp.xap?ver=1"/>

太棒了!甚至在Windows Phone开发中也有工作

我已经说过了:

NavigationService.Navigate(new Uri("/Game.xaml?versao="+version, UriKind.RelativeOrAbsolute));
然后覆盖导航到的方法
on

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    base.OnNavigatedTo(e);
    string var;
    if (NavigationContext.QueryString.TryGetValue("version", out var))
    {
        ...
    }
}

遇到.XAP缓存并不罕见,这意味着每次部署新版本的Silverlight应用程序时,浏览器都不会下载更新的.XAP文件

一种解决方案是更改IIS属性。您可以通过以下步骤为.XAP文件启用“启用内容过期HTTP头”选项:

Open IIS Manager
Go to “Default Web Site” and find web site for your Silverlight project.
Find the .XAP file under ClientBin.
Go to the properties page of the .XAP file, on HTTP Headers Tab, Turn on “Enable Content Expiration”, click the “Expire Immediately” radio button.
Save the changes.
这样,当您刷新页面而不必关闭浏览器时,最新的.XAP(仅当存在最新的.XAP文件时)将被下载


希望这有帮助

将以下web.config放入ClientBin

<configuration>
  <system.webServer>
    <staticContent>
      <clientCache cacheControlMaxAge="0.00:00:01" cacheControlMode="UseMaxAge"/>
    </staticContent>
  </system.webServer>
</configuration>

这里提到的解决方案和其他帖子始终没有帮助我。
我最后做的是手动将.xap和.svc文件从我的发布版本分别复制到ClientBin和Service deployment文件夹。

该值是否与程序集版本(即1.0.0.0)关联?@Chris否这完全是虚构的。您可以将任何内容放在那里,只要您想将更改下推到客户端时对其进行更改。不过,最好的做法可能是使它与您的版本控制保持一致。这对我不起作用。我使用以下方法解决了这个问题:我在host.aspx文件中将这个querystring值的设置添加到部署脚本中。我再也不用想它了,它就像一个符咒!请注意,我们已经有了pragma nocache集,但它并不适用于我们所有的客户。