gpt4 book ai didi

c# - 无法从我的解决方案访问配置管理器

转载 作者:可可西里 更新时间:2023-11-01 08:05:22 24 4
gpt4 key购买 nike

我有一个三层设置。有人建议我应该从 Web.Config 文件中获取 ConnectionString,我已将其设置如下:

alt text

现在我正尝试从我的 DAL 层访问 ConnectionString,但找不到 ConfigurationManager。我怎样才能从这里调用我的连接字符串?:

alt text

最佳答案

添加对 System.Configuration 的引用,然后为 System.Configuration 提供一个使用类,然后您将可以访问:

ConfigurationManager.ConnectionStrings

你的可以通过

访问
string s = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

关于c# - 无法从我的解决方案访问配置管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1355610/

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