gpt4 book ai didi

c# - 如何从另一个类库项目中的 app.config 获取连接字符串?

转载 作者:行者123 更新时间:2023-11-30 16:17:22 25 4
gpt4 key购买 nike

如何从另一个“类库项目”中的 app.config 获取连接字符串

在同一个类库中我可以使用这段代码:

 DAL.Properties.Settings.Default.BayrueConnectionString;

但问题是我无法从我的网络应用程序中获取它。

谢谢 enter image description here

最佳答案

我认为没有比这更优雅的方式了。向返回它的类库添加一个静态帮助器方法。

public sealed class Helper
{
private Helper()
{
}

public static string GetBayrueConnectionString()
{
return DAL.Properties.Settings.Default.BayrueConnectionString;
}
}

关于c# - 如何从另一个类库项目中的 app.config 获取连接字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17291644/

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