vb.net - App.config - LocalSqlServer 连接字符串

标签 vb.net

请参阅下面的代码:

Public Shared Sub SyncConnectionStrings()
    Dim strCon As String
    Dim tyDatabase As typeDatabase
    Dim boolConfigChanged As Boolean
    'Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
    Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
    Dim strConnectionString As ConnectionStringSettings            
    For Each strConnectionString In ConfigurationManager.ConnectionStrings
        'More code here, but irrelevant for this question.
    Next
End Sub

代码循环遍历 app.config 文件中的所有连接字符串。 app.config 中有三个连接字符串,但找到了四个连接字符串。 LocalSqlServer(这是 ConfigurationManager.ConnectionStrings.Name)定义在哪里?

最佳答案

它在位于

的 Machine.config 全局文件中定义
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\CONFIG".

它是在安装 NET.Framework 时生成的,并且是在 ASPNETDB 上运行的工具所需要的

如果你不需要它,你可以尝试将其添加到你的app.config

<connectionStrings>
<clear/>
.....

或者也

<connectionStrings>
<remove name="LocalSqlServer" />

我真的建议不要更改 Machine.Config 中的任何内容,除非您知道副作用。

关于vb.net - App.config - LocalSqlServer 连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16416654/

相关文章:

asp.net - OneDrive 静默身份验证

c# - VB.Net中的主要功能在哪里

vb.net - 防病毒软件 SONAR.Heuristic 检测到的小型 VB.NET 应用程序

sql - 改进我的数据访问层

mysql - 如何将bak文件转换成sql文件(支持sql bak文件转mysql)并执行该文件自动恢复

vb.net - 访问 Azure 云存储 - CloudConfigurationSettings

VB.NET - 实现 IDisposable 时是否应该添加 Finalize 方法?

vb.net - 在命令提示符下运行多行 vb.net

vb.net - 克隆一个列表(类)

javascript - 服务器正在尝试将 HTML 表内的 Repeater 控件转换为 HtmlTableRow