【发布时间】:2015-03-03 18:55:53
【问题描述】:
Visual studion 2013 MVC5(读取可移植类库的 app.config 值时出错)。我有两个项目
- 网络应用程序
- 可移植类库。
我在类库项目的 app.config 中使用了我想要的键值 读取我的类文件,但因为 System.Configuration 类在库项目中不可用,所以我无法从 app.config 中读取值:
<appSettings>
<add key="xyz" value="123" />
</appSettings>
当我试图在类库的一个类文件中读取值时
public class mytest
{
public static string AppValue=
System.Configuration.ConfigurationManager.AppSettings["xyz"].ToString();
}
当我尝试使用 System.Configuration 时,我收到了 The 'configuration' element is not declared 的错误,我没有在类库中得到这个。
【问题讨论】:
-
您可能缺少
System.Configuration的程序集引用
标签: c# asp.net-mvc-5