tags:

views:

44

answers:

1

In my ClickOnce c# application, how can I tell if the user just updated the application? I would like to offer to show the release notes or the change log after the user has downloaded the update.

I know how I can programmatically (spelling?) detect if an update is available, and manually perform the update. I could show the changelog or release notes then, but I'd like the option to do it after the update, if possible. My Googlefu has failed me.

+2  A: 

I'm not sure if there is or isn't a Framework mechanism for this.

But you may be able to handle this manually yourself. If you or the publishing wizard is updating your Version # for each build, you can store the Version # from the last time the app ran on the machine locally (Registry/AppData/Whatever) and then compare that with your current version #. If the version #'s don't match you can set the local 'last run version' and then display the release notes.

You can fetch the version for app using something like:

private string version
{
    get
    {
        System.Reflection.Assembly _assemblyInfo = System.Reflection.Assembly.GetExecutingAssembly();

        string ourVersion = string.Empty;

        if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
        {

            ourVersion = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
        }
        else
        {
            if (_assemblyInfo != null)
            {
                ourVersion = _assemblyInfo.GetName().Version.ToString();
            }
        }

        return ourVersion;
    }
}
Ruddy
Yeah. I was hoping there was a framework thingy.
yodaj007
A quick look at ApplicationDeployment brings me to http://msdn.microsoft.com/en-us/library/system.deployment.application.applicationdeployment.isfirstrun.aspx which may be something you can use. It says "The value of this property is reset whenever the user upgrades from one version to the next" which seems like what you want to know.
Ruddy
Ruddy, you are a beautiful person. Thank you!
yodaj007