Home > View Post

ClickOnce File Groups

ClickOnce is a little gem.

It was whilst working through the xbap tutorial in the WPF Hands on labs that I came across File Groups.

Some enterprises are wary of ClickOnce because they fear that when they release a new version of the software, their network will be swamped with network traffic. Of course, ClickOnce is clever enough to only download the parts of the application that have changed but what about that first 'big' download?

Well, thanks to File Groups, there are even ways you can help break this down. Imagine your application ships a number of images in the deployment folder but they're only needed if/when you get to section X of an application. Maybe you have a large dll that you reference but don't use until you get to section X of an application. Then don't download it until you need to!

Simply put the file into a different application group (on the Publish tab of your project properties and click the 'Application Files' button)...

ClickOnce File Groups

Now you can use the ClickOnce API to download this File Group on demand or 'Just In Time' :)

public void Login(string username)
{
    if (ApplicationDeployment.IsNetworkDeployed &&
        !ApplicationDeployment.IsFileGroupDownloaded("XBoxClient"))
    {
// we need to use the XBoxClientService to login but the proxy is in a file called XBoxClient.dll which
// was added to the XBoxClient File Group so won't have downloaded yet. Let's download it now.
        ApplicationDeployment.CurrentDeployment.DownloadFileGroup("XBoxClient");
    }
    
// Now we can call a method that calls our XBoxClient - note we need a seperate method because the CLR
// compiles methods on demand - if we had a direct reference to the XBoxClient.dll inside this method
// then the JIT compile would fail
    SeparateMethodForJit(username);
}

public void SeparateMethodForJit(string username)
{
    XBoxClientService service = new XBoxClientService();
    service.Login(username);
}

Tidy.

Tags: .NET

 
Josh Post By Josh Twist
1:52 AM
23 May 2007

» Next Post: SharedSize and the Grid
« Previous Post: WPF Hands on labs

Comments are closed for this post.

© 2005 - 2017 Josh Twist - All Rights Reserved.