Visual studion 2013 MVC5 (读取可移植类库的 app.config 值时出错)。我有两个项目
- 网络应用程序
- 可移植类库。
我在我想要的类库项目的 app.config 中使用了键值读取我的类文件,但由于系统配置类在库项目中不可用,所以我无法从 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
时收到错误,我在类库中没有得到这个。
请确保您的 web 配置文件中提供以下配置
<appSettings>
<add key="xyz" value="123" />
</appSettings>