DEBUG: Error 2769: Custom Action install did not close 1 MSIHANDLEs.

You may have seen this strange error when trying to install your MSI when you have developed a managed custom action DLL in Visual Studio 2005 / 2008?

If you execute the MSI with detailed logging, like this:
MSIEXEC /i "<YOURMSI>.msi" /L*v "InstallLog.txt"

You end up with an error message that is similar to this in the log file:
DEBUG: Error 2769:  Custom Action _E3EBB591_EA21_438E_AEB9_4442A5A8C483.install did not close 1 MSIHANDLEs.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2769. The arguments are: _E3EBB591_EA21_438E_AEB9_4442A5A8C483.install, 1,
Action ended 16:09:12: InstallExecute. Return value 3.

The thing is that you probably have set the Custom Action Data as follows:
/myParameter=”[TARGETDIR]”
The solution to the problem is to add a trailing backslash:
/myParameter=”[TARGETDIR]\

This is actually described in this MSDN article:
http://msdn.microsoft.com/en-us/library/2w2fhwzz.aspx

How to debug Custom Actions in a MSI setup package

So you have come to the conclusion that you will need to debug custom actions in a MSI setup package?. How do you do it? Well, it’s very simple, just add the following line in your custom action code:

Debugger.Break();

And now when you launch the MSI package, it will break and prompt you with the following dialog:

Choose debugger

Just select the desired debugging environment and start debugging. It’s as simple as that!