[英]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.我正在为 64 位计算机在 Visual Studio 2010 中编写安装程序。 There I'm using a custom action to get the value of a CheckBox
in the installation process.我在安装过程中使用自定义操作来获取CheckBox
的值。
The custom Action is as follows:自定义Action如下:
/cbvalue="[CHECKBOXA1]"
and in my installer class I have added the following code to get the parameter:在我的安装程序 class 中,我添加了以下代码来获取参数:
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.....错误: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.如果您使用自定义操作创建 64 位安装程序,请始终记住您会收到此错误,因为自定义操作始终使用 x86 架构来构建,您需要使用相同的自定义操作,然后使用 ORCA 工具编辑您的 msi 请参阅此链接相同。
Did you add custom parameter in Install(), like this:您是否在 Install() 中添加了自定义参数,如下所示:
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());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.