System.Configuration.ConfigurationManager.AppSettings not wo
本文关键字:not wo AppSettings ConfigurationManager Configuration System | 更新日期: 2023-09-27 18:06:01
下面是我的app.config文件
<configuration>
<appSettings>
<add key="input_file" value="D:'bioen'Web'NewUser'dotnet'PasswordGenerator'AutoPassword'AutoPassword'Passwords.txt"/>
<add key="location" value="sequals"/>
</appSettings>
</configuration>
当我试图在如下所示的程序中读取这些值时,两个字符串都为空。为什么会这样?
string path = System.Configuration.ConfigurationManager.AppSettings["input_file"];
string location = System.Configuration.ConfigurationManager.AppSettings["location"];
最可能的问题是您缺少对System.Configuration.dll的引用。
右键单击项目,添加引用到系统。
- 应用程序。Config用于读取设计时的配置,例如实体框架从中读取。
- 强类型设置需要在项目属性页的设置选项卡中添加。您可以选择它们的作用域,例如Application或User。这些将被添加到设置中。项目设计文件。
应用程序设置通过My.Settings.