【发布时间】:2011-05-27 05:06:31
【问题描述】:
我正在尝试提取保存到 app.config 文件中的 URL,但它返回一个空白字符串。任何想法为什么?
string asdf = String.Format("{0}", ConfigurationManager.AppSettings["MemberUrl"]);
还有配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ForumUrl" value="http://www.dreamincode.net/forums/xml.php?showforum=" />
<add key="MemberUrl" value="http://www.dreamincode.net/forums/xml.php?showuser=" />
</appSettings>
</configuration>
【问题讨论】:
-
普通 .NET 应用程序还是在另一个进程下运行?
-
只是一个普通的旧 App.config 文件添加到我的解决方案中。没有其他进程接触它。
-
是控制台应用程序、Windows 服务还是 Web 应用程序?
-
只是一个观察,你有什么理由在这里打扰
string.Format("{0}", ...,你什么时候可以直接分配它? -
@Sergio 我知道当我在 explorer 下运行一个 .NET 应用程序时,它会寻找 explorer.exe.config 大声笑
标签: c# app-config