【问题标题】:"Unrecognized configuration section connectionStrings" in app.exe.configapp.exe.config 中的“无法识别的配置节 connectionStrings”
【发布时间】:2011-01-30 03:13:52
【问题描述】:

在我的 .NET 2.0 WinForms 应用程序的终端服务器安装中,我的一个客户端在启动时出现以下异常: “无法识别的配置部分连接字符串” 这发生在 myapp.exe.config 中,但我不知道为什么。在其他任何地方都可以完美运行,此安装与其他安装的唯一区别是连接字符串。

我四处搜索,但只能在 web.config 中找到与 ASP.NET 应用程序和问题有关的这个问题。 有什么想法可以在这个 WinForms 应用程序的配置中被破坏吗?是否表明 machine.config 中存在问题?

仅供参考,myapp.exe.config 的顶部是:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
  <section name="MyApp.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
  <section name="MyApp.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings>
    <add name="MyApp.DataAccessLayer.Settings.MyConnectionString" connectionString="$$$$$$" providerName="System.Data.SqlClient" />
</connectionStrings>
...

谢谢

理查德

【问题讨论】:

    标签: .net winforms configuration app-config


    【解决方案1】:

    在 configSections 标签内添加:

    <section name="connectionStrings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=jjjjjjjj" requirePermission="false" />
    

    【讨论】:

    • 好的,我知道如何解决它。问题是,为什么不需要将其他安装添加到 myapp.exe.config 中?另外,不应该将其定义为 ConnectionStringsSection 类型吗?
    【解决方案2】:

    尽管问题的实际原因是(不知何故!)损坏的 .NET Framework 安装,但上述答案有效。重新安装/修复 .NET 安装解决了该问题。

    【讨论】:

    • 我遇到了类似的问题,结果我的 machine.config 已被删除。
    猜你喜欢
    • 1970-01-01
    • 2011-06-13
    • 1970-01-01
    • 1970-01-01
    • 2016-08-24
    • 2010-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多