Wix安装程序-在安装过程中捕获用户输入 [英] Wix installer- capture user input during install

查看:90
本文介绍了Wix安装程序-在安装过程中捕获用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是WiX的新手,我一直在努力为winform c#应用程序构建基于WiX的安装程序,在此我想在安装过程中捕获用户名和密码,然后保存在app.config中并对应用程序进行加密.安装后的配置文件.我成功地构建了基于WixUI_mondo的对话框,以捕获输入并加密app.config文件.但是,在捕获输入并使用自定义操作保存到app.config时遇到了问题.代码如下.我是WiX的新手,安装程序很紧急,请帮助我解决此问题.

I am a newbie in WiX and I have been struggling to build a WiX based installer for my winform c# application where I want to capture username and password during the installation and then save in app.config as well as encrypt the app.config file after post installation. I am successful in building the WixUI_mondo based dialogs for capturing the input as well as encrypting the app.config file. However I am facing problem while capturing the input and saving to app.config using custom actions. The code is given below. Please help me to resolve this as I am a newbie in WiX and the installer is urgent.

<pre lang="c#">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Deployment.WindowsInstaller;
using System.Configuration;
namespace CustomAction
{
public class CustomAction
{
    [CustomAction]
    public static ActionResult saveSales(Session session)
    {

        string salesPass = session["sales_pwd"];
        var fileMap = new ExeConfigurationFileMap();
        fileMap.ExeConfigFilename = "myApp.exe.config";
        var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
        config.AppSettings.Settings["salesPass"].Value =salesPass;
        config.Save(ConfigurationSaveMode.Modified);
        ConfigurationManager.RefreshSection("appSettings");
        return ActionResult.Success;
    }
    [CustomAction]
    public static ActionResult saveSuper(Session session)
    {
        string adminPass = session["admin_pwd"];
        var fileMap = new ExeConfigurationFileMap();
        fileMap.ExeConfigFilename = "myApp.exe.config";
        var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
        config.AppSettings.Settings["superPass"].Value = adminPass;
        config.Save(ConfigurationSaveMode.Modified);
        ConfigurationManager.RefreshSection("appSettings");
        return ActionResult.Success;
    }
}
}





并在product.wsx文件中:






and in the product.wsx file:


<InstallExecuteSequence>
  <Custom Action='saveSales' After='InstallFinalize'>NOT Installed</Custom>
  <Custom Action='saveSuper' After='saveSales'>NOT Installed</Custom>

</InstallExecuteSequence>

<Binary Id="CustomAction.dll" SourceFile="$(var.caPath)\CustomAction.CA.dll" />
<CustomAction Id="saveSales" BinaryKey="CustomAction.dll"

  DllEntry="saveSales" Execute="immediate" />
<CustomAction Id="saveSuper" BinaryKey="CustomAction.dll"

  DllEntry="saveSuper" Execute="immediate" />




当我注释掉以下几行时,安装程​​序将正常运行.任何的想法??




when I commented out the following the following lines then the installer runs properly. any idea??

config.AppSettings.Settings["superPass"].Value = adminPass; config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings");







推荐答案

(var.caPath)\ CustomAction.CA.dll" / > < CustomAction =" saveSales" BinaryKey CustomAction.dll " DllEntry =" =" 立即" / > < CustomAction =" saveSuper" BinaryKey CustomAction.dll " DllEntry =" =" 立即" / >
(var.caPath)\CustomAction.CA.dll" /> <CustomAction Id="saveSales" BinaryKey="CustomAction.dll" DllEntry="saveSales" Execute="immediate" /> <CustomAction Id="saveSuper" BinaryKey="CustomAction.dll" DllEntry="saveSuper" Execute="immediate" />




当我注释掉以下几行时,安装程​​序将正常运行.任何的想法??




when I commented out the following the following lines then the installer runs properly. any idea??

config.AppSettings.Settings["superPass"].Value = adminPass; config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings");








这篇关于Wix安装程序-在安装过程中捕获用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆