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

标签 c# visual-studio-2010 installation setup-project custom-action

我正在 Visual Studio 2010 中为 64 位计算机编写安装程序。我在安装过程中使用自定义操作获取 CheckBox 的值。

自定义Action如下:

/cbvalue="[CHECKBOXA1]"

在我的安装程序类中,我添加了以下代码来获取参数:

string myInput = Context.Parameters["cbvalue"];

安装项目构建成功,但是当我尝试安装安装文件时,在安装过程中出现以下错误:

Error: 1001 System.BadImageFormatException.could not load an assembly.....

当我在不添加自定义操作的情况下尝试此操作时,它会正确安装。 而且我还想找到一种调试安装项目的方法。

最佳答案

你是否在 Install() 中添加了自定义参数,如下所示:

public override void Install(System.Collections.IDictionary stateSaver) 
{ 
   base.Install(stateSaver); 
   stateSaver.Add("cbvalue", Context.Parameters["cbvalue"].ToString()); 
}

所以你应该有这样的东西:

public override void Commit(System.Collections.IDictionary savedState) 
{ 
   base.Commit(savedState); 
   System.Windows.Forms.MessageBox(savedState["bcvalue"].ToString());    
}

关于c# - 如何在 Visual Studio 2010 中为 C# 安装程序编写自定义操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6288538/

相关文章:

c# - 从程序集中删除强签名

c# - 文本框对象的文本更改事件 : how to perform text change + another action

c# - 如何使用C#显示打印机属性

.net - MSTest:以64位模式运行单元测试

sql-server - 我无法在 VS2010 中为 SQL Server Express 创建数据库图表

python - 尝试安装 Python 音频工具时 make install 失败

linux - zImage 安装在 Raspberry PI 2 上

c# - ServiceStack.Text 和 DeserializeFromString 其中 Json 名称是非法的

css - 如何在 .less 文件上打开 Visual Studio 2010 .css Intellisense

c# - 如何与数据库文件一起编写安装程序?