【问题标题】:How to change app.config from the MSI installer, designed on Visual Studio?如何从在 Visual Studio 上设计的 MSI 安装程序更改 app.config?
【发布时间】:2009-07-28 18:23:43
【问题描述】:

我有这个 .NET 应用程序,它使用 Settings.settings 和 app.conf 作为配置存储库,而不是 Windows 注册表。在安装过程中向用户提问并将响应写入 Windows 注册表似乎很容易,但我还没有找到将响应写入 app.config 文件的方法。有人知道怎么做吗?

【问题讨论】:

    标签: .net visual-studio visual-studio-2008 installation windows-installer


    【解决方案1】:

    我做过这样的项目,要求用户在安装过程中提供所有参数。您可以创建包含所有标签、文本框和按钮的自定义表单。并在您的安装程序类中使用该表单作为您的安装程序类的属性。

    这是一个例子

    [RunInstaller(true)]
    public partial class MyCustomInstaller : Installer
    {
          private MyCustomForm = new MyCustomForm();
          // this is your custom form that allows users to modify the configuration parameters.
    }
    

    然后你可以像这样捕获事件:

      private void InitializeComponent()
      {
          this.AfterInstall += new System.Configuration.Install.InstallEventHandler(DoConfigurationManagement_AfterInstall);
      }
    

    【讨论】:

      【解决方案2】:

      您可以查看this,它解释了如何使用 CustomActions 从 msi 安装程序更改 app.config 文件。

      【讨论】:

      • 404 为这个链接,以后请做一个简短的总结以避免这个问题。你知道链接是否在其他地方处于活动状态?
      猜你喜欢
      • 1970-01-01
      • 2014-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多