Csharp/C#教程:ConfigurationManager.ConnectionStrings从machine.config返回额外的连接字符串分享


ConfigurationManager.ConnectionStrings从machine.config返回额外的连接字符串

我正在写一个Windows服务,我需要在App.config中定义的所有连接字符串的列表。

我使用System.Configuration.ConfigurationManager.ConnectionStrings来获取所有连接。

它总是返回这个额外的连接:

data source =。 SQLEXPRESS; Integrated Security = SSPI; AttachDBFilename = | DataDirectory | aspnetdb.mdf; User Instance = true

我认为是在machine.config中添加的。

我的App.config是:

 

无论如何,我只能得到App.config中定义的连接字符串(不是machine.config中的那个)

我可以删除它,但我想知道是否有更清洁的方式!

谢谢

尝试在添加之前添加清除:

上述就是C#学习教程:ConfigurationManager.ConnectionStrings从machine.config返回额外的连接字符串分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

     

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/983212.html

(0)
上一篇 2021年12月19日
下一篇 2021年12月19日

精彩推荐