How to update XBAP to latest version on client computer?
Asked Answered
P

7

22

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.

Punish answered 6/5, 2011 at 14:16 Comment(0)
H
2

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)

Harbaugh answered 3/11, 2011 at 15:44 Comment(4)
That method does not seem to exist in an XBAPHebner
I tested with IE, FireFox, and Chrome, and they all fail to download the new version.Hebner
CheckAndDownloadUpdateAsync seems to be a Silverlight-only function, not WPF/XBAP.Unders
for WPF; replace the above code with new System.Deployment.Application.DeploymentServiceCom().CleanOnlineAppCache(); - courtesy of #11775338Resolvent
D
2

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.

Dichroite answered 21/1, 2012 at 17:3 Comment(0)
E
0

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

    //https://mcmap.net/q/126855/-disable-browser-cache-for-entire-asp-net-website
//http://developer.yahoo.com/performance/rules.html#expires
//http://ray.jez.net/prevent-client-side-caching-with-httpmodules/
//https://mcmap.net/q/500528/-making-the-silverlight-xap-file-expire-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
}
Encyclopedist answered 8/11, 2011 at 1:58 Comment(5)
Won't this re-download the app anytime it gets run? The whole point of caching it is so it doesn't re-download, which I like because it makes the startup time faster.Hebner
only on new releases will it re-download. The url created is based on the host website AssemblyVersion (i keep it the same as the app using linked files). So caching still works. If you dynamically download new assemblies you may still have the same caching problems that can be resolved with compositewpf.codeplex.com/discussions/…Encyclopedist
Do you know how to implement this in an XBAP? (or if it is even possible?) The code and link you posted both look like they're for Silverlight only.Hebner
the link is not specific to sl, it is more specific to the prism infrastructure and how you manage assemblies on demand. I actually have this in my backlog to implement but haven't had time. I currently have caching disabled permanently until i build the loader. I rather have a slow download than a broken app. I've added the httpmodule i built to disable caching for .xap .. you can add your extensions for files being cached and not updated. (added to the original comment)Encyclopedist
I am still unclear how I would implement this in an XBAP, which is a WPF application that runs in a Web Browser, not a Silverlight application. I don't use MVC, or PRISM (other than the NotificationObject and EventAggregator), and .xap is the the extension for Silverlight. My bounty ends in about half an hour, and I still don't have an answer about how I can fix this issue so I am letting it expire. If your solution does actually work in XBAPs then I'll add a 2nd bounty and give you the points.Hebner
N
0

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).

Norword answered 8/11, 2011 at 4:59 Comment(1)
I want to keep the app embedded in the website, and ClickOnce will make it run outside the site. Also, the load time of ClickOnce apps is more than I prefer.Hebner
M
0

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.

Margay answered 15/12, 2011 at 13:34 Comment(0)
O
0

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

Ongoing answered 5/1, 2012 at 9:17 Comment(0)
T
0

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.

Taryn answered 14/8, 2012 at 8:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.