简体   繁体   中英

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 parameter:

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.

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.

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());    
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM