Answered by:
unable to debug custom action/installer class

Question
-
1. The VS2005 documentation for ‘Troubleshooting Windows Installer Deployment’ describes 3 techniques for debugging a custom action/installer class. I am not able to get any of them to work. For reference purposes, the C# code for MyInstaller is as follows:
public partial class MyInstaller : Installer
{
public InstallContext installContext = new InstallContext();
… additional code…
public override void Install( System.Collections.IDictionary stateSaver )
{
base.Install( stateSaver );
if( installContext.IsParameterTrue( "MyParameter" ) == true ) {
MessageBox.Show( "writing to log file" );
installContext.LogMessage( "MyInstaller::Install - message 1" );
}
installContext.LogMessage( "MyInstaller::Install - message 2" );
System.Diagnostics.Debugger.Launch();
//MessageBox.Show( "Debug Me" );
}
… additional code…
};
Debugging technique #1 - Add a call in your code to System.Diagnostics.Debugger.Launch
Nothing happens when I add this to the code. The setup runs and then displays the message that it has completed. How do I get this to work?Debugging technique #2 - Add a call in your code to MessageBox.Show("Debug Me").
Attempting to attach to the MessageBox process generates the message, “Unable to attach to the process. The system cannot find the file specified”. How do I tell the debugger where the setup.exe file is or what do I have to do to get this to work?Debugging technique #2 - Set your debugging preferences to start InstallUtil.exe
Can anyone explain how this is done? I’ve not found anything in the [Tools][Debugging] options or the [Debug] menu options where this can be done.2. A) Where can the the log file message be found that is written by ‘installContext.LogMessage? Is this the correct way to log messages?
B) To pass data to my installer, the CustomActionData has been set to: /MyParameter=true. However, the condition ‘if ( installContext.IsParameterTrue( "MyParameter" ) == true )’ is never true and ‘MessageBox.Show( "writing to log file" )’ never gets executed. Can someone explain the correct CustomActionData that I need to define?Thanks,
Ian
Wednesday, April 16, 2008 2:41 PM
Answers
-
I don't know how 1) and 2) could work. Your code is running on an msiexec.exe process (in VS 2005 it'll be an impersonated local DCOM call to an msiexec.exe process running your custom action, not the msiexec service process).
If 3) mentions InstallUtil.exe then it's not the Windows Installer you're using. They're recommending using InstallUtil.exe to call your installer classes, so you're not going to see any issues that might br associated with running in an msiexec.exe process.
Your condition looks wrong to me because what you pass in to CustomActionData is string type, so you need to checking for "true", not true, and, I'd do a Trim in case there are spaces in your CustomActionData string.
MessageBox.Show() might work, but the whole business of showing UI during the execute sequence of the MSI install is tricky. The msiexec process running the install expects all UI to have been collected up front, and is not set up to deal with pumping messages during custom action calls.
Wednesday, April 16, 2008 8:11 PM
All replies
-
I don't know how 1) and 2) could work. Your code is running on an msiexec.exe process (in VS 2005 it'll be an impersonated local DCOM call to an msiexec.exe process running your custom action, not the msiexec service process).
If 3) mentions InstallUtil.exe then it's not the Windows Installer you're using. They're recommending using InstallUtil.exe to call your installer classes, so you're not going to see any issues that might br associated with running in an msiexec.exe process.
Your condition looks wrong to me because what you pass in to CustomActionData is string type, so you need to checking for "true", not true, and, I'd do a Trim in case there are spaces in your CustomActionData string.
MessageBox.Show() might work, but the whole business of showing UI during the execute sequence of the MSI install is tricky. The msiexec process running the install expects all UI to have been collected up front, and is not set up to deal with pumping messages during custom action calls.
Wednesday, April 16, 2008 8:11 PM -
Hello Phil,
Thanks for helping out. As you can probably tell, I'm just starting to work with custom action in the installer and trying to figure out how things work. The code I showed has been copied from several other examples (e.g. included in the VS2005 documentation -
It sounds like I might be missing the bigger picture. Is there documentation you can refer me to (other than the online material) that provides a clearer picture of how to use the setup/deployment feature in VS2005?
Thanks again,
Ian
Wednesday, April 16, 2008 8:37 PM -
Please see this http://musingsandshouts.blogspot.com/2009/05/debugging-custom-installer-class.html
- Proposed as answer by mkmurray Monday, October 19, 2009 10:30 PM
Tuesday, May 5, 2009 9:13 AM -
Please see this http://musingsandshouts.blogspot.com/2009/05/debugging-custom-installer-class.html
i had the same problem, the solution in the above link worked. thanks.
ZBThursday, May 7, 2009 10:09 PM -
Hi ,
Please see this http://musingsandshouts.blogspot.com/2009/05/debugging-custom-installer-class.html
Even I had the same problem, the solution in the above link worked. Thanks
_____________________________________________________________-
Bhaskar - http://vsxperts.blogspot.com
Bhaskar MCPD:WinForms http://vsxperts.blogspot.comSaturday, June 6, 2009 2:07 AM