来自OdbcConnection.Open()的奇怪exception

在这里抨击我们的头撞墙

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

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

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

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,根据要求:

     
http://ourdomain.com/OurService.asmx

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

检查machine.config和user.config。 与app.config一起,这些是组成配置部分的3 。

Reflector显示EnsureInit有2个exception路径:

 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; } 

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

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

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

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