简体   繁体   English

如何在 Visual Studio 2010 中为 c# 安装程序编写自定义操作?

[英]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.

相关问题 安装程序C#Visual Studio 2010中的文件夹路径输入 - folder path input in installer c# visual studio 2010 如何为我的 Visual Studio 2010 C# 项目制作安装程序? - How do I make an installer for my Visual Studio 2010 C# project? 如何使用Visual Studio 2010为C#Web服务项目创建.msi安装程序? - How do I create an .msi installer with Visual Studio 2010 for a C# webservices project? C#Visual Studio 2010:制作自定义预设类 - C# Visual Studio 2010: make custom preset classes XSL编辑/开发的自定义控件C#Visual Studio 2010 - Custom Control for XSL editing/development C# Visual Studio 2010 如何将Microsoft Visual C ++ 2010 SP1与我的Visual Studio安装程序项目一起打包 - How do I package Microsoft Visual C++ 2010 SP1 with my Visual Studio installer project 如何在C#中制作可视的可重用类?(Visual Studio 2010) - How to make a visual reuasable class in C#?(Visual Studio 2010) 如何在C#/ Visual Studio 2010中将自定义SQL字符串或参数传递给tableadapter或诸如此类? - How do I pass a custom SQL string or parameters to a tableadapter or somesuch in C# / Visual Studio 2010? 在C#自定义操作中更改安装程序属性 - change installer properties in C# custom action 使用Visual Studio的自定义安装程序 - Custom installer with Visual Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM