gpt4 book ai didi

c# - ConfigurationManager.AppSettings 越来越空?

转载 作者:IT王子 更新时间:2023-10-29 04:10:05 28 4
gpt4 key购买 nike

我没有意识到:“在单独的类库中有一个 web.config 并且”正在从不同的 Web 应用程序读取 web.config 应用程序设置。

我正在使用 VS2010 目标框架 3.5

我不知道这里出了什么问题,但是当我尝试获取 ConfigurationManager.AppSettings["StoreId"];

时,我得到了 null
private string _storeid = GetStoreId;

public static string GetStoreId
{
get
{
return ConfigurationManager.AppSettings["StoreId"];
}
}

web.config:

<appSettings>
<add key="StoreId" value="123" />
</appSettings>

最佳答案

如果您正在UNIT TESTING,您需要UNIT TEST PROJECTAPP.CONFIG副本

关于c# - ConfigurationManager.AppSettings 越来越空?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4280970/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com