【发布时间】:2013-12-20 06:34:59
【问题描述】:
我有一个安装程序类,它正在从 Visual Studio 安装项目中检索参数。现在打开 exeConfiguration 我收到以下错误..
Error 1001:An error occurred loading a configuration file.
The parameter 'exePath' is invalid.
Parameter name:exepath-->The Parameter 'exePath' is invalid.
Parameter name:exePath
这是我的 Installer.cs 代码..
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
string targetDirectory = Context.Parameters["targetdir"];
string param1 = Context.Parameters["Param1"];
string param2 = Context.Parameters["Param2"];
string param3 = Context.Parameters["Param3"];
string exePath = string.Format("{0}TechSoft CallBill.exe", targetDirectory);
Configuration config = ConfigurationManager.OpenExeConfiguration(exePath);
config.AppSettings.Settings["Param1"].Value = param1;
config.AppSettings.Settings["Param2"].Value = param2;
config.AppSettings.Settings["Param3"].Value = param3;
config.Save();
}
请帮我解决这个错误,因为我无法弄清楚。 任何建议都受到热烈欢迎。 在此先感谢
【问题讨论】:
-
您是否尝试加载属于不同项目的配置?还是属于安装程序类项目?
-
@AccessDenied 非常感谢先生。配置属于安装程序类项目。这里我附上项目类路径图像。
-
@AccessDenied 请先生告诉我哪里出错了?
-
检查我的答案,试试那个代码。它应该可以工作。
标签: c# configuration installation string-formatting configurationmanager