CodeKicks.com
Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Thursday, August 24, 2006

Automatic Updation from VB 6.0 to VB.NET

Introduction

Deploying applications is hard. It takes time to build and test installers. Applications often require additional COM components to operate, and these components require registration. You also have to consider how you're going to physically distribute the bits. Will you burn a CD? Will you zip them up and place them on a website for downloading? Will you use a product like SMS to push them out?

Versioning applications is also hard. You may have previous versions of the application installed that may require removal. Applications today are expected to somehow know when a new version is available, prompt you to see whether you want to install it, and then take care of the rest.

Visual Basic 6.0 allows you to build installers to address some of these issues. Third-party products offer even more capabilities for deploying and versioning application, but automatic updating can be tricky. Visual Basic 6.0 provides no capabilities for making an application that automatically detects, downloads, and installs a new version of itself. Rolling your own capability for this would be, for lack of a better term, hard.

ClickOnce Deployment

Automatic application updating is a feature that Microsoft has been working to simplify. With Visual Studio 2005 and the .NET Framework 2.0, Microsoft provides a built-in solution for robust application deployment and automatic updating. While this technology, known as ClickOnce deployment, was developed with .NET applications in mind, it can be used to automate the deployment and updating of Visual Basic 6.0 applications. Considering that bazillions of lines of Visual Basic 6.0 code will continue to run in production for some time, this might be a useful thing.

Getting Started

To begin with ClickOnce deployment, it's important to have the latest version of Visual Studio. If you already have Visual Studio 2005 installed, that's great! Otherwise, I strongly recommend that you download and install the free Visual Basic Express. Visual Basic Express provides all the functionality that you need in order to ClickOnce deploy applications. It's a free, trimmed-down version of the full Visual Studio 2005, but unlike typical evaluation software, it doesn't timeout.

This article will walk you, step by step, through the process of ClickOnce deploying a Visual Basic 6 application. The steps in this article are written for Windows XP with Internet Information Server (IIS) installed. This technique should work on other versions of Windows, but the steps for configuring Internet Information Server will vary slightly.

The first steps will walk you through using Visual Basic Express to ClickOnce deploy a Visual Basic .NET application. This .NET application will become the launcher for your Visual Basic 6.0 application. It will check for, download, and install new versions automatically.

  1. Start Visual Basic Express or Visual Studio 2005.
  2. Click the File menu, and then click New Project.
  3. Create a Visual Basic Windows Application. Name the application MyAppLauncher.
  4. Click the File menu, and then click Save All.
  5. In the Save Project dialog box that appears, click Save.

    You should now see the form designer, which will let you create the launcher application. Initially, this will be a trivial application that will let you get familiar with ClickOnce deployment. Later, this will include your Visual Basic 6.0 application, and you will see how it can automatically update itself.

  6. In the Solution Explorer, double-click My Project.
  7. Click the Publish tab on the left side.

    The Publish tab shows the options related to ClickOnce deployment (see Figure 1). When you ClickOnce deploy your application, it will be posted on a website, allowing the user to download, install, and execute the application with a single click. The application will also download and install any needed prerequisites, such as the .NET Framework 2.0.

  8. On the Publish tab, click Prerequisites if you want to select additional packages to download and install with your application (see Figure 2). The .NET Framework 2.0 is a requirement, but you might also want to download and install MDAC 2.8, for example.

  9. On the Publish tab, click Updates to configure when the application checks for new versions (see Figure 3). The default is to check before the application starts, but you can have the application check in the background while it's running.

  10. On the Publish tab, click Publish Now to compile and deploy the application to your local Web server. Once the application has been deployed, the Web page in Figure 4 will be displayed, allowing you, or any other user, to download and install the prerequisites and the application.

Post a Comment