how to write custom action for a c# installer in visual studio 2010?
I am writing an installer in Visual Studio 2010 for a 64 bit computer. There I'm using a custom action to get the value of a CheckBox
in the installation process.
The custom Action is as follows:
/cbvalue="[CHECKBOXA1]"
and in my installer class I have added the following code to get the paramete开发者_Go百科r:
string myInput = Context.Parameters["cbvalue"];
The setup project builds successfully, but when I try to install the setup file, during the installation, it gives the following error:
Error: 1001 System.BadImageFormatException.could not load an assembly.....
When I'm try this without adding the custom action, it gets installed properly. And also I want to find a way to debug the setup projects.
Did you add custom parameter in Install(), like this:
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
stateSaver.Add("cbvalue", Context.Parameters["cbvalue"].ToString());
}
So you should've got something like this:
public override void Commit(System.Collections.IDictionary savedState)
{
base.Commit(savedState);
System.Windows.Forms.MessageBox(savedState["bcvalue"].ToString());
}
If you are creating 64 bit installer using custom actions, always remember you will get this error, as custom actions always use x86 architecture to built, you need to use the same custom action and then edit your msi using ORCA Tool see this link to do the same.
精彩评论