来自OdbcConnection.Open()的奇怪异常

时间:2009-05-21 15:52:05

标签: c# .net winforms exception

将头撞在墙上

我们是ISV,有数百家公司使用我们的软件没有任何问题。该软件是.NET 2.0上的Winforms / C#。

我们的一位客户安装了我们的软件,它在所有机器的启动时崩溃,除了一个人的笔记本电脑,它工作正常。

在调用OdbcConnection.Open()时,我们得到以下异常:

The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception.
  at System.Transactions.Diagnostics.DiagnosticTrace.get_Verbose()
  at System.Transactions.Transaction.get_Current()
  at System.Data.Common.ADP.IsSysTxEqualSysEsTransaction()
  at System.Data.Common.ADP.NeedManualEnlistment()
  at System.Data.Odbc.OdbcConnection.Open()
  at OurCompany.OurForm.connectionTestWorker_DoWork(Object sender)

这有一个InnerException:

Configuration system failed to initialize
  at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
  at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
  at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
  at System.Configuration.ConfigurationManager.GetSection(String sectionName)
  at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
  at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()

谷歌只是说“app.config在语法上是不正确的,重建它”但同样的app.config在数百台其他机器上运行良好。

这是app.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="OurApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <system.diagnostics>
  </system.diagnostics>
  <applicationSettings>
    <OurApp.Properties.Settings>
      <setting name="OurApp_WebServices_OurServiceName" serializeAs="String">
        <value>http://ourdomain.com/OurService.asmx</value>
      </setting>
    </OurApp.Properties.Settings>
  </applicationSettings>
  <appSettings>
    <add key="WorkflowEngine" value="old" />
    <add key="ProductID" value="3" />
    <add key="EnableMigrationWizard" value="false" />
    <add key="UseAlternativeFtpPort" value="true" />
    <add key="FeedbackWhileConnecting" value="true" />
  </appSettings>
</configuration>

修复.NET Framework并没有解决这个问题。我完全失去了。有什么想法吗?

4 个答案:

答案 0 :(得分:3)

检查machine.config和user.config。与app.config一起,这些是3 that make up the config sections

反射器显示EnsureInit有2个异常路径:

catch (Exception exception) {
    this._initError = new ConfigurationErrorsException(SR.GetString("Config_client_config_init_error"), exception);
    throw this._initError;
} catch {
    this._initError = new ConfigurationErrorsException(SR.GetString("Config_client_config_init_error"));
    throw this._initError;
}

由于第二只会处理一个non-CLS exception,我猜你正在击中第一个。{}如果是这种情况,您可能需要递归地通过InnerException来获取完整的详细信息。

答案 1 :(得分:0)

只是对于任何人未来的参考,我在我的桌面上开发的本地应用程序遇到了这个问题,发现问题只是因为我遇到了错误的情况。一旦修复它再次像魅力一样。

答案 2 :(得分:0)

通过使用来自同一SP /补丁级别的另一台计算机的已知工作副本覆盖machine.config来解决此问题。

答案 3 :(得分:0)

尝试使用ASP / VB.NET 3.5 SP1打开OLE DB连接时,发生了同样的错误。如果我将我的URL添加到IE中的可信站点列表,则错误消失并且连接成功打开。我不知道这是否会解决其他浏览器中的问题。