Blog Archives

C# Create a Windows Installer Class Custom Action bootstrap DLL in .Net

The standard windows installer project included with Visual Studio right out of the box is great in many deployment scenarios.

For more advanced needs, organizations and developers usually defer to 3rd party solutions, such as InstallShield, Wise, wix or NSIS (NullSoft).

These solutions are all very well tested and have minimal learning curve in a lot of cases. However, if you are tight on budget or simply looking for the experience and full customization, you can also create your own custom action installer class in Visual Studio.

Simply create a new DLL project included in the same solution as your windows installer project. From the Windows Installer Project go to “File System” and in your Application Folder add “Project Output” and select your new DLL. Now go to the “custom actions” tab and under install and/or uninstall right click and “Add Custom Action” then select the output under Application Folder. That’s it!

Make sure the class for your DLL has “RunInstaller” attributes and looks similar to the snippet below. You may also want to do some light reading on the “CustomActionData” property to see if there are any variables you may need such as “ProductCode”.

To change the custom action data property, from the custom action tab simply select your DLL output after adding it, and expand the Visual Studio Properties tab on the side.

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;

namespace MSIBootstrap
    public partial class InstallHelper : Installer
        public static string InstallTitle = "Discount Notes"; //used by install/uninstall to get window handle
        public InstallHelper()

        public override void Install(System.Collections.IDictionary stateSaver)
try {
//your custom code
catch (Exception ex) {
throw new InstallException(ex.ToString());

 public override void Uninstall(System.Collections.IDictionary stateSaver)
//mimic same try/catch design pattern if you like

With this approach, you are essentially using the standard windows installer project to bootstrap your custom action DLL.

This is very powerful, and allows you to define your own code logic and conditions as well as custom interfaces and forms designed directly from within Visual Studio.

Wise installer,
wix installer,
Nullsoft NSIS,
Wikipedia (bootstrapping),,, (persisting savedState),
MSDN, “CustomActionData”,