如何在客户端计算机上将XBAP更新到最新版本?

发布于 2024-11-06 03:52:20 字数 630 浏览 1 评论 0原文

我开发了一个嵌入 ASP.NET 网页中的 XAML 浏览器应用程序 (XBAP)。我在客户端计算机上更新最新版本的 XBAP 时遇到问题。在开发过程中,我必须使用 Mage.exe 工具清除应用程序缓存,以便在本地计算机上运行时可以看到我的更改。除了在命令行中执行 Mage.exe -cc 之外,我还发现 rundll32 dfshim CleanOnlineAppCache 也能正常工作。

但是,我不想要求客户在命令行中运行任何命令。我需要做什么才能使 XBAP 在客户端计算机上自动更新?以前版本的 XBAP 继续运行,而不是在客户端计算机上刷新更新的 XBAP。

更新

我针对这个问题创建了赏金,因为我遇到了同样的问题。根据我在网上阅读的内容,XBAP 应该将缓存的版本 # 与网络服务器上的版本 # 进行比较,如果不同,则下载新版本。我已验证我的版本号不同,但缓存的副本仍然是我启动 XBAP 时正在运行的版本。

如果我在 asp.net 页面之外启动 XBAP,也会出现缓存的副本,尽管如果我更改 url 参数,我确实会获得新版本。

更新 #2

我发现 XBAP 会在 XP 32 位计算机上自动更新,但不会在我的 Windows 7 64 位计算机上自动更新。

I developed a XAML browser application (XBAP) that is embedded within an ASP.NET web page. I am having a problem getting the latest version of the XBAP to update on the client computer. During development, I have had to use the Mage.exe tool to clear out the application cache so that my changes will be seen when running on my local computer. Besides executing Mage.exe -cc in the command line, I have also found rundll32 dfshim CleanOnlineAppCache to work just as well.

However, I do not want to ask customers to run any commands in the command line. What will I have to do to make the XBAP automatically update on the client computer? Instead of the updated XBAP refreshing on the client computer, the previous version of the XBAP continues to run.

Update

I created a bounty on this question because I have the same issue. From what I read online, XBAPs are supposed to compare the cached version # with the version # of the one on the webserver, and download the new version if it's different. I've verified that my version numbers are different, but the cached copy is still the one that is running when I launch the XBAP.

The cached copy also comes if I launch the XBAP outside of the asp.net page, although I do get the new version if I change the url parameters.

Update #2

I've discovered that the XBAP does automatically update on XP 32-bit machines, but not on my Windows 7 64-bit machine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

死开点丶别碍眼 2024-11-13 03:52:21

几年前,我们在一个普通的网站上遇到了这个问题。它一直困扰着我们,最后,我们改变了每个新版本的 url 前缀。第一个页面从未被缓存,并转发到更新后的 URL。

我知道,这是一种解决方法,但非常可靠。

Years ago, we had this problem with an ordinary website. It kept haunting us, and in the end, we ended up changing the url prefix for each new version. The very first page was never cached, and forwarded to the updated url.

Its a workaround, I know, but a very reliable one.

独孤求败 2024-11-13 03:52:21

您可以使用 ClickOnce 部署您的应用程序。如果您想强制用户更新,只需设置应用程序所需的最低版本(位于“应用程序更新”对话框中)。

You can use ClickOnce to deploy your application. If you want to force user to update just set minimum required version for the application (it's in Application Updates dialog box).

岛歌少女 2024-11-13 03:52:21

如果没有正确的缓存标头,您的浏览器可能会阻止下载 xbap。

清除缓存以查看是否可以修复该问题。

或者使用:

<%string versionInfo = typeof (AVSTX.POS.WebMvc.Controllers.HomeController).Assembly.GetName().Version.ToString(); %>
<param name="source" value="<%=ResolveUrl("~/ClientBin/AVSTX.POS.WebRia.xap?version=" + versionInfo) %>"/>

创建一个浏览器此时无法缓存的新 url。
它基于检查主机程序集版本,因此请确保增加
[程序集:AssemblyVersion(“3.4.9.0”)]
[程序集:AssemblyFileVersion(“3.4.9.0”)]

此解决方案不会解决您将来可能下载的动态模块。如果这是您的问题,您将需要修复实际的缓存标头。

编辑1:禁用浏览器缓存的代码

    //http://stackoverflow.com/questions/1160105/asp-net-mvc-disable-browser-cache
//http://developer.yahoo.com/performance/rules.html#expires
//http://ray.jez.net/prevent-client-side-caching-with-httpmodules/
//http://stackoverflow.com/questions/2281919/expiry-silverlight-xap-file-from-browser-cache-programmatically
public class XapFileHttpModule : IHttpModule
{
    #region IHttpModule Members

    public void Init(HttpApplication context)
    {
        context.BeginRequest += context_BeginRequest;
    }

    public void Dispose()
    {
    }

    private void context_BeginRequest(Object source, EventArgs e) 
    {
        HttpApplication application = (HttpApplication)source;
        HttpContext context = application.Context;

        if(context.Request.FilePath.Contains(".xap"))
        {
            context.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
            context.Response.Cache.SetValidUntilExpires(false);
            context.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            context.Response.Cache.SetNoStore(); 
        }
    }

    #endregion
}

without the correct cache headers your browser may be preventing downloading the xbap.

clear cache to see if this fixes it.

alternatively use:

<%string versionInfo = typeof (AVSTX.POS.WebMvc.Controllers.HomeController).Assembly.GetName().Version.ToString(); %>
<param name="source" value="<%=ResolveUrl("~/ClientBin/AVSTX.POS.WebRia.xap?version=" + versionInfo) %>"/>

to create a new url which the browser cannot cache at this point.
It is based on inspecting the host assembly version so make sure to increment
[assembly: AssemblyVersion("3.4.9.0")]
[assembly: AssemblyFileVersion("3.4.9.0")]

this solution won't solve the dynamic modules you may download in the future. you will need to fix the actual cache headers if this is your problem.

edit 1: code to disable browser caching

    //http://stackoverflow.com/questions/1160105/asp-net-mvc-disable-browser-cache
//http://developer.yahoo.com/performance/rules.html#expires
//http://ray.jez.net/prevent-client-side-caching-with-httpmodules/
//http://stackoverflow.com/questions/2281919/expiry-silverlight-xap-file-from-browser-cache-programmatically
public class XapFileHttpModule : IHttpModule
{
    #region IHttpModule Members

    public void Init(HttpApplication context)
    {
        context.BeginRequest += context_BeginRequest;
    }

    public void Dispose()
    {
    }

    private void context_BeginRequest(Object source, EventArgs e) 
    {
        HttpApplication application = (HttpApplication)source;
        HttpContext context = application.Context;

        if(context.Request.FilePath.Contains(".xap"))
        {
            context.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
            context.Response.Cache.SetValidUntilExpires(false);
            context.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            context.Response.Cache.SetNoStore(); 
        }
    }

    #endregion
}
清风无影 2024-11-13 03:52:21

应用程序缓存是通过清单文件缓存完成的,当清单签名更改时,运行时将升级本地文件(而且它只升级更改的文件)。只需确保您在 HTTP 响应上发送了正确的标头即可。有时动态页面缓存设置或托管提供商全局设置会产生干扰。对我来说,它总是开箱即用。

Application caching is done via manifest files caching, when manifests signatures changes, runtime will upgrade the local files (moreover it just upgrade the changed files). Just sure that you has the right headers sent on HTTP responses. Sometimes dynamic pages cache settings or hosting providers global settings interfere. For me, it always works out of the box.

为你拒绝所有暧昧 2024-11-13 03:52:21

ClickOnce 对我来说就像魅力一样。还要确保您正确控制 XBAP 的版本。

ClickOnce worked for me like a charm. Also make sure that you're versioning your XBAP properly.

国产ˉ祖宗 2024-11-13 03:52:21

我通过简单地将 filest 复制到我的 Web 项目中的 ClientBin 目录来部署 Xbap。
我在 iframe 中显示它。
为了使应用程序“刷新”版本,我必须在构建之前更改 Xbap 项目中的“发布版本”。
项目属性->发布->发布版本。

这会更改 xbap 和清单文件中的版本,迫使客户端下载最新版本。

I deploy my Xbap by simply copying filest to ClientBin directory in my web project.
I display it in iframe.
To make application "refresh" version I have to change "Publish Version" in Xbap project before build.
Project Properties -> Publish -> Publish Version.

This changes version in xbap and manifest file forcing clients to download newest version.

血之狂魔 2024-11-13 03:52:20

你可以尝试这样的事情,虽然我在 XAP 而不是 XBAP 中使用它,但它也可能对你有用:(

下面是片段)

public partial class App : Application
{
    /// <summary>
    /// Creates a new <see cref="App"/> instance.
    /// </summary>
    public App()
    {
        Application.Current.CheckAndDownloadUpdateAsync();
        // rest of code

编辑

本来建议在发布之间增加版本号,但似乎已经得到了照顾的。所有浏览器上都会出现此行为吗?可能是一些特定于 IE 的错误/奇怪的地方(我见过很多仅 IE 的不当行为......不会让我感到惊讶)

You could try something like this, although I use it in XAPs not XBAPs it might work for you too:

(snippet follows)

public partial class App : Application
{
    /// <summary>
    /// Creates a new <see cref="App"/> instance.
    /// </summary>
    public App()
    {
        Application.Current.CheckAndDownloadUpdateAsync();
        // rest of code

EDIT

Was gonna suggest incrementing version number between publishes but it seems that's already been taken care of. Does this behavior happen on all browsers ? Might be some IE-specific bug/oddity (i've seen plenty of IE-only misbehaviors... wouldn't surprise me)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文