Click here to Skip to main content
15,881,248 members
Articles / Programming Languages / C#

SmartClient: .NET Self Updating Applications

Rate me:
Please Sign up or sign in to vote.
2.73/5 (14 votes)
4 May 2007CPOL7 min read 84.1K   714   59   12
Smart Client: Self Updating Applications using Updater application block & Click Once functionality provided by VS.NET 2005

Introduction

The term Smart Client was coined to highlight the differences between the typical "Rich Client" applications of yesteryear and the next generation of client applications. Smart Client applications can be deployed and updated from a Centralized web server. Once deployed, smart client software applications can automatically update themselves to the latest version of the software that resides on the centralized server. We can implement this functionality in any Project in two different ways:

  1. Using Microsoft's Updater Applications Block
  2. ClickOnce deployment technique provided in VS.NET 2005

1) Updater Application Block

Microsoft's application blocks: "Updater Application Block" is used for the above purposes but using this, we have some limitations like:

  • The block relies on absolute path links being provided in the configuration file. This reliance causes big problems, because you can't always guarantee that users will install your application to a specific location.
  • When you want to add a new file to be updated, you have to modify a manifest file to set the file path for each file.
  • A version is a set of files. So, if you want to update just one file you have to prepare a new update folder with a new manifest.

The above limitations can be removed by extending the updater block with the interface IValidator, IPostProcessor & IDownloader but the other problem with the Updater application block is that it only supports .NET 1.1 Frameworks, i.e. the framework .NET 1.1 must be installed on the machines. Even if .NET 1.1 Framework is present on the system, it can't be used for .NET 2.0 applications because it doesn't supports the machine.config file settings on the machine/system.

2) ClickOnce

ClickOnce is a deployment technology that enables self-updating Windows-based applications that can be installed and run with minimal user interaction. ClickOnce deployment overcomes three major issues inherent in deployment:

  • Difficulties in updating applications. With Microsoft Windows Installer deployment, whenever an application is updated, the user must reinstall the entire application; with ClickOnce deployment, you can provide updates automatically. Only those portions of the application that have changed are downloaded, then the full, updated application is reinstalled from a new side-by-side folder.
  • Impact to the user's computer. With Windows Installer deployment, applications often rely on shared components, with the potential for versioning conflicts; with ClickOnce deployment, each application is self-contained and cannot interfere with other applications.
  • Security permissions. Windows Installer deployment requires administrative permissions and allows only limited user installation; ClickOnce deployment allows non-administrative users to install and grants only those Code Access Security permissions necessary for the application.

The core ClickOnce deployment architecture is based on two XML manifest files: an application manifest and a deployment manifest.

The application manifest describes the application itself, including the assemblies, the dependencies and files that make up the application, the required permissions, and the location where updates will be available. The application developer authors the application manifest by using the Publish Wizard in Visual Studio 2005 or the manifest generation tool (Mage.exe) in the .NET Framework SDK.

The deployment manifest describes how the application is deployed, including the location of the application manifest, and the version of the application that clients should run. An administrator authors the deployment manifest using the manifest generation tool (Mage.exe) in the .NET Framework SDK.

To make a ClickOnce application available to users, you must publish it to a Web server; file share, or removable media. You can publish the application using the Publish Wizard; additional properties related to publishing are available on the Publish page of the Project Designer or you can publish the application on the server manually.

[Source: http://msdn2.microsoft.com/en-us/library/wh45kb66.aspx]

To Publish to Web Using Publish Wizard

  1. In Solution Explorer, select the application project.
  2. Right-click the project node and choose Publish. The Publish Wizard appears.
  3. On the Where do you want to publish the application? page, enter a valid URL using the format http://localhost/foldername, then click Next.
  4. In the Will the application be available offline? page, click the appropriate option:
    1. If you want to enable the application to be run when the user is disconnected from the network, click Yes, this application will be available online or offline. A shortcut on the Start menu will be created for the application.
    2. If you want to run the application directly from the publish location, click No, this application is only available online. A shortcut on the Start menu will not be created. Click Next to continue.
  5. Click Finish to publish the application.
    Publishing status is displayed in the status notification area of the taskbar.

To Publish the application manually on Web Server

To publish your application on the Web Server without using the publish wizard is little bit tricky. For this, please follow the steps given below:

  1. Please create one folder under wwwroot folder for example YourClickOnceApplication.
  2. Create one subfolder under YourClickOnceApplication,
    for example YourClickOnceApplication _1_0_0_0 since first time you are publishing application.
  3. Copy your .exe, .dlls, resource files\folders & config files from bin\Release folder into YourClickOnceApplication _1_0_0_0.
  4. Go to Start-->Program-->Microsoft .NET Framework SDK v2.0-->SDK Command Prompt & type MageUi.exe one window will open
  5. Create a new application manifest by selecting File, New, Application Manifest from the menu.
  6. On the default Name tab, enter the name and version number of this deployment.
  7. Select the Files tab and click the Browse... button next to the Application Directory text box.
  8. Select the directory containing your application files that you created in step 2, and click OK on the folder selection dialog box.
  9. Click the Populate button to add all your application files to the file list. If your application contains more than one executable file, mark the main executable file for this deployment as the startup application by selecting Entry Point from the File Type drop-down list. (If your application only contains one executable file, MageUI.exe will mark it automatically for you.)
  10. Select the Permissions Required tab and select the level of trust you need your application to assert. The default is Full Trust, which will be suitable for most applications.
  11. Select File, Save from the menu, and save the application manifest. You will be prompted to sign the application manifest when you save it. Save it in folder created in step 2 (i.e. under YourClickOnceApplication _1_0_0_0 folder).
  12. Select File, New, Deployment Manifest from the menu to create your deployment manifest, and then on the Name tab, supply a name and version number (1.0.0.0 in this example).
  13. Select the Publisher tab, and supply values for Publisher and Product. (Product is the name given to your application on the Windows Start menu when you install your application locally.)
  14. Switch to the Deployment tab, select the Application type as Install locally and give the URL of the virtual directory which you have created in step1 named YourClickOnceApplication like here you can give http://localhost/ YourClickOnceApplication/YourAppName.application.
  15. Switch to the Update tab, and specify how often you would like this application to update. If your application uses the ClickOnce Deployment API to check for updates itself, clear the check box labelled this application should check for updates if not check the checkbox Also you can define the way your application will self update.
  16. Switch to the Application Reference tab. You can pre-populate all of the values on this tab by clicking the Select Manifest button and selecting the application manifest you created in the step 9.
  17. Choose Save and save the deployment manifest to disk. You will be prompted to sign the application manifest when you save it. Save deployment manifest in folder created in step 1 (i.e. under YourClickOnceApplication folder).
    That's it. Now browse .application file from location given in step 12 for example.

http://localhost/ YourClickOnceApplication/YourAppName.application.

Now the next time when you will publish your applications' new version, what you have to do is create a folder named YourClickOnceApplication _2_0_0_0 and put your new EXE, DLLs all other files and again create the application manifest file for this folder using mageui tool. Again you have to change the reference of application manifest file in the deployment manifest file. To do this, just open the deployment manifest file using mageui tool created in step 10 and change the application manifest path in Application Reference tab and save the file in the same location.

Now when you will run your application, it will ask that a new version is updated on server and whether you want to install or not. If you say yes, then it will download all the latest files from the server and reinstall the application on your system.

License

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


Written By
Technical Lead Aristocrat Technologies India Pvt. Ltd.
India India
I am MCAD certified ,working with Aristocrat Technologies(www.aristocratgaming.com).

Comments and Discussions

 
GeneralMy vote of 1 Pin
jmta161-Dec-09 10:14
jmta161-Dec-09 10:14 
GeneralPublishing Pin
George Hendrickson19-May-08 6:05
professionalGeorge Hendrickson19-May-08 6:05 
Generaluninstall option Pin
tnaveen16-Oct-07 1:07
tnaveen16-Oct-07 1:07 
QuestionWhat about i want to encrypt .exe before publishing ? Pin
VBNewComerVBDOTNET3-Jun-07 4:37
VBNewComerVBDOTNET3-Jun-07 4:37 
QuestionNeed help for offine application Pin
Sanjay Arya17-Jan-07 19:17
Sanjay Arya17-Jan-07 19:17 
Questionsource files link is broken? Pin
DannSmith28-Sep-06 4:03
DannSmith28-Sep-06 4:03 
AnswerRe: source files link is broken? Pin
vivekgaur28-Sep-06 20:09
vivekgaur28-Sep-06 20:09 
GeneralNot that all that many know this... Pin
_alank28-Sep-06 2:56
_alank28-Sep-06 2:56 
GeneralRe: Not that all that many know this... Pin
vivekgaur29-Sep-06 0:10
vivekgaur29-Sep-06 0:10 
GeneralRe: Not that all that many know this... Pin
_alank29-Sep-06 3:15
_alank29-Sep-06 3:15 
Questionmore details? Pin
DannSmith28-Sep-06 2:24
DannSmith28-Sep-06 2:24 
AnswerRe: more details? Pin
vivekgaur28-Sep-06 2:39
vivekgaur28-Sep-06 2:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.