Click here to Skip to main content
13,292,913 members (87,783 online)
Click here to Skip to main content
Add your own
alternative version


10 bookmarked
Posted 29 Jul 2007

Adding Custom Dialog to Visual Studio .NET 2003 Project

, 29 Jul 2007
Rate this:
Please Sign up or sign in to vote.
Visual Studio custom action provides the option to add predefined custom dialogs, however there is no option to add our own custom dialog. The following class can be used to add the custom dialog. We can create a DLL using the following class and custom dialogs.


This is useful when custom actions are required in the installer while Visual Studio .NET 2003 is used to build the setup using the setup/deployment project.


Visual Studio 2003 does not have an option to add the custom dialogs. It has some predefined dialogs which can be used for any custom actions. If we want to have our own custom dialog, we have to follow the class given below.

Using the Code

This is a generic class which can be used as given here. We need to create a project resulting in a DLL and add this class to the project. Add multiple dialogs required to be launched at the end of the installation.

using System;
using System.Configuration.Install;
using System.ComponentModel;
using System.Collections;
using System.Windows.Forms;

namespace CustomDialogLauncherSpace
     /// <summary>
     /// Summary for Custom Dialof launcher
     /// </summary>
     public class CustomDialogLauncher : System.Configuration.Install.Installer
          private string InstallDir;
          public CustomDialogLauncher()
              // TODO: Add constructor logic here
         // Overridden Install method which will get called first.
         public override void Install(IDictionary savedState)
              // Get the install path
              string TheAssemblyPath = this.Context.Parameters["assemblypath"];
              InstallDir = TheAssemblyPath.Substring
			(0, TheAssemblyPath.LastIndexOf("\\"));
              // Display the custom dialog

              // If you want you can use InstallDir else, skip
              CustomDialog custDialog = new CustomDialog(InstallDir);
              DialogResult result = custDialog.ShowDialog();
              if(result != DialogResult.OK)
                   DialogResult rollBack = MessageBox.Show
			("This will roll back the installation, are you sure", 
			"Installation", MessageBoxButtons.YesNo, 
                   if(DialogResult.Yes == rollBack)
                       throw new InstallException("Installation aborted, rolling back");

         // Overridden Uninstall method which will get called during un install.
         public override void Uninstall(IDictionary savedState)
        // Overridden Rollback method which will get called 
        // during installation rollback
        public override void Rollback(IDictionary savedState)
        public override void Commit(IDictionary savedState)

Add the multiple custom dialogs required in the setup project in the same project. Call all the dialogs in the Install() function in the sequence required. Once the new DLL is created, add the DLL to Application folder using Add Custom action. Select the Add file button to add the newly built DLL.


  • 30th July, 2007: Initial post 


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


About the Author

Sandeep. Vaidya
Web Developer
India India
I am a software engineer working from 1997 in differnt plotform and variety of applications.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171207.1 | Last Updated 30 Jul 2007
Article Copyright 2007 by Sandeep. Vaidya
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid