【问题标题】:how to read c# config file of your program with external startup program如何使用外部启动程序读取程序的 c# 配置文件
【发布时间】:2016-04-20 01:26:02
【问题描述】:

我有一个向 Excel 添加一些功能的项目。现在的设置方式包括添加“C:.....\Excel.exe”作为启动操作(在调试>启动操作>启动外部程序下)

现在我有一个配置文件 (app.config),但是当我使用 ConfigurationManager 读取配置项时,它读取的是 C:...\Excel.exe.config 文件而不是 Myapplication.exe.config(或app.config)

有没有办法让它读取我的 application.exe.config?我尝试过 ConfigurationManager.OpenExeConfiguration() 方法,但使用此方法似乎无法枚举配置项

【问题讨论】:

标签: c# vsto config configurationmanager


【解决方案1】:

使用这个:

Configuration config = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = "pathToConfigFile" }, ConfigurationUserLevel.None);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多