Click here to Skip to main content
15,896,063 members
Articles / Programming Languages / Visual Basic

Adding automatic updates to your program - Part 1

Rate me:
Please Sign up or sign in to vote.
4.86/5 (64 votes)
31 Dec 2007CPOL6 min read 1.1M   11.7K   430  
This article describes the steps to add automatic update capabilities to your application quickly and easily using the DDay.Update library.
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

using DDay.Update.Utilities;
using DDay.Update.Configuration;

[[AssemblyAttributes]]

namespace DDay.Update.Bootstrap
{
    class Program
    {
        static private ILog log = new Log4NetLogger();

        static void Main(string[] args)
        {
            // Get the DDay.Update configuration section
            DDayUpdateConfigurationSection cfg = ConfigurationManager.GetSection("DDay.Update")
                as DDayUpdateConfigurationSection;

            // Set the command line parameters to the application
            UpdateManager.SetCommandLineParameters(args);

            // Determine if an update is available
            if (UpdateManager.IsUpdateAvailable(cfg.Uri))
            {
                log.Debug("Update is available, beginning update process...");

                // Perform the update, which performs the following steps:
                // 1. Updates to a new version of the application
                // 2. Saves new deployment and application manifests locally
                // 3. Starts the application
                UpdateManager.Update();
            }
            else
            {                
                log.Debug("Application is up-to-date.");

                // Start the application
                UpdateManager.StartApplication();
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
Doug has been a Software Engineer for 7 of the previous 9 years, and has 12 years of programming experience.

For the past 3 years, he has been developing custom applications in C# and Visual Basic.NET, with an emphasis on custom cross-Internet applications for IT management, real-time collaboration, and process management and reporting.

Comments and Discussions