代码之家  ›  专栏  ›  技术社区  ›  Stephan Keller

为什么我的ConnectionStringCollection中的条目比app.config中的“我的连接字符串”部分多?

  •  2
  • Stephan Keller  · 技术社区  · 15 年前

    在我的C#-WinForms应用程序(.Net 3.5,VS2008)中,我使用以下命令读取App.Config:

    Configuration myConfig = 
      ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
    

    <connectionStrings>
        <add name="db1" connectionString="connection1"
         providerName="System.Data.SqlClient"/>
        <add name="db2" connectionString="connection2"
          providerName="System.Data.SqlClient" />
    </connectionStrings>
    

    (为了便于阅读,省略了连接字符串)

    我的 app.config 作为来源。附加字符串已被删除 无效的 作为源代码,所以我认为.net是从某处变出来的。

    如何删除此条目,或者如果无法删除,如何告诉configuration manager仅使用app.config中的连接字符串?

    2 回复  |  直到 15 年前
        1
  •  6
  •   Richard    15 年前

    你查过了吗 machine.config

    (发现于 %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\CONFIG Framework64 .)

        2
  •  2
  •   Stephen Newman    15 年前

    <clear />
    

    到元素的顶部。