【WinForm】“System.Data.SqlClient.SqlConnection”的类型初始值设定项引发异常,无法识别的配置节 system.serviceModel
出现问题的原因:
在本机上没有出现问题,让一个同事测试的时候,在另外一台电脑上出现连接数据库失败,系统不能打开的问题
在网上搜了一下,有说是数据库连接字符串错误的,有说app.config文件配置不匹配等原因的。总之是没有解决这个问题
出现问题的错误信息,不全,只给出了主要的信息:如下
错误描述:Void .ctor()
System.TypeInitializationException: “System.Data.SqlClient.SqlConnection”的类型初始值设定项引发异常。 ---> System.TypeInitializationException: “System.Data.SqlClient.SqlConnectionFactory”的类型初始值设定项引发异常。 ---> System.TypeInitializationException: “System.Data.SqlClient.SqlPerformanceCounters”的类型初始值设定项引发异常。 ---> System.Configuration.ConfigurationErrorsException: 配置系统未能初始化 ---> System.Configuration.ConfigurationErrorsException: 无法识别的配置节 system.serviceModel。 (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config line 146)
在 System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
在 System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
在 System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
在 System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
--- 内部异常堆栈跟踪的结尾 ---
在 System.Configuration.ConfigurationManager.PrepareConfigSystem()
在 System.Configuration.ConfigurationManager.GetSection(String sectionName)
在 System.Configuration.ConfigurationManager.get_AppSettings()
在 log4net.Util.SystemInfo.GetAppSetting(String key)
--- 内部异常堆栈跟踪的结尾 ---
在 System.Data.SqlClient.SqlConnectionFactory..cctor()
--- 内部异常堆栈跟踪的结尾 ---
在 System.Data.SqlClient.SqlConnection..cctor()
--- 内部异常堆栈跟踪的结尾 ---
在 System.Data.SqlClient.SqlConnection..ctor()
在 System.Data.SqlClient.SqlConnection..ctor(String connectionString)
在machine.config的文件里面的serviceModel信息如下:
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="persistenceProvider" type="System.ServiceModel.Configuration.PersistenceProviderElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="workflowRuntime" type="System.ServiceModel.Configuration.WorkflowRuntimeElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="enableWebScript" type="System.ServiceModel.Configuration.WebScriptEnablingElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="webHttp" type="System.ServiceModel.Configuration.WebHttpElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</behaviorExtensions>
<bindingElementExtensions>
<add name="webMessageEncoding" type="System.ServiceModel.Configuration.WebMessageEncodingElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="context" type="System.ServiceModel.Configuration.ContextBindingElementExtensionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</bindingElementExtensions>
<bindingExtensions>
<add name="wsHttpContextBinding" type="System.ServiceModel.Configuration.WSHttpContextBindingCollectionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="netTcpContextBinding" type="System.ServiceModel.Configuration.NetTcpContextBindingCollectionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="webHttpBinding" type="System.ServiceModel.Configuration.WebHttpBindingCollectionElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="basicHttpContextBinding" type="System.ServiceModel.Configuration.BasicHttpContextBindingCollectionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</bindingExtensions>
</extensions>
<client>
<metadata>
<policyImporters>
<extension type="System.ServiceModel.Channels.ContextBindingElementImporter, system.workflowservices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
</policyImporters>
<wsdlImporters>
<extension type="System.ServiceModel.Channels.ContextBindingElementImporter, system.workflowservices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
</wsdlImporters>
</metadata>
</client>
</system.serviceModel>
不知道这个信息的作用是什么。
解决方法:
问题应该处在了 .net 的C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config 文件里。可能是这期间安装其他软件导致配置文件被修改。
解决办法:将machine.config用同在一个目录下的machine.config.default替换。
另:
还有人给出这样的解决方法,没有试过,各位遇到这种问题可以自己试一下是否可行
【WinForm】“System.Data.SqlClient.SqlConnection”的类型初始值设定项引发异常,无法识别的配置节 system.serviceModel的更多相关文章
- “System.Data.SqlClient.SqlConnection”的类型初始值设定项引发异常---解决方案
"System.Data.SqlClient.SqlConnection"的类型初始值设定项引发异常 问题出在了 .net 的C:\WINDOWS\Microsoft.NET\Fr ...
- “SYSTEM.DATA.SQLCLIENT.SQLCONNECTION”的类型初始值设定项引发异常---解决方案
“System.Data.SqlClient.SqlConnection”的类型初始值设定项引发异常 问题出在了 .net 的C:\WINDOWS\Microsoft.NET\Framework\v2 ...
- System.Data.Entity.Internal.AppConfig 类型初始值设定项引发异常
在一开始时将connectionStrings 写在了configSections之上如下图一示,结果抛出:“System.Data.Entity.Internal.AppConfig”的类型初始值设 ...
- “System.Transactions.Diagnostics.DiagnosticTrace”的类型初始值设定项引发异常[WCF]
未处理System.TypeInitializationException HResult=-2146233036 Message=“System.ServiceModel.Diagnostics ...
- “System.Transactions.Diagnostics.DiagnosticTrace”的类型初始值设定项引发异常。
今天在项目中用log4net,App.config文件中增加了configSections节点,程序运行报错“System.Transactions.Diagnostics.DiagnosticTra ...
- 关于WPF System.windows.Media.FontFamily 的类型初始值设定项引发异常问题解决方法
造成原因:此问题的根本原因是.NET Framework January 2018 Rollup(KB4055002)与已安装的.NET Framework 4.7.1产品版本之间的MSI安装交互.R ...
- 使用EF访问数据库,出现“System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发异常。
今天在使用的EF时候,发生了"System.Data.Entity.Internal.AppConfig"的类型初始值设定项引发异常.这样的一个错误 查了原因,原来是appconf ...
- C#使用NLOG System.TypeInitializationException,类型初始值设定项引发异常
C#如何使用NLOG,网上有很多介绍,本次使用时遇到一个问题,使用NLOG写日志时,出现初始化异常,基本异常信息如下: System.AggregateException: 发生一个或多个错误. -- ...
- Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache的类型初始值设定项引发异常。 ---> System.IO.FileLoadException: 未能加载文件或程序集
场景: 安装程序到全新的环境的电脑时中(此时已经安装了能正常安装程序电脑的环境) 完整错误: Application_ThreadException:System.TypeInitialization ...
随机推荐
- hadoop2 作业执行过程之作业提交
hadoop2.2.0.centos6.5 hadoop任务的提交常用的两种,一种是测试常用的IDE远程提交,另一种就是生产上用的客户端命令行提交 通用的任务程序提交步骤为: 1.将程序打成jar包: ...
- 保持查询语法指示的联接顺序Option(Force order)
Option(Force order) 今天和大家分享一下 SQL中强制执行联接顺序Option(Force Order) 一.SQL本身SQL引擎优化已经做的非常好了,但是也有默认的多表连接引擎效果 ...
- How do you render tooltip on disabled HTML Button
This idea's based on the following (x)html: <form><fieldset><buttondisabledtitle=&quo ...
- [Java] 关键字final、static使用总结
一.final 根据程序上下文环境,Java关键字final有“这是无法改变的”或者“终态的”含义,它可以修饰非抽象类.非抽象类成员方法和变量.你可能出于两种理解而需要阻止改变:设计或效率.final ...
- 使用JSON进行数据传输的总结
一.选择的意义 在异步应用程序中发送和接收信息时,可以选择以纯文本和 XML 作为数据格式.为了更好的使用ajax, 我们将学习一种有用的数据格式 JavaScript Object Notation ...
- xe5 android sample 中的 SimpleList 是怎样绑定的
C:\Users\Public\Documents\RAD Studio\12.0\Samples\FireMonkeyMobile 例子中的绑定方式如下图: 1.拖拽一个listview到界面上,然 ...
- CF Set of Strings
Set of Strings time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 转:Android官方MVP架构示例项目解析
转自: http://www.infoq.com/cn/articles/android-official-mvp-architecture-sample-project-analysis 作者 吕英 ...
- 关于ios项目沙盒中的文件和Xcode项目创建的文件
//1.1获取在Xcode项目打开的情况下创建的Plist文件 NSString *path = [[NSBundle mainBundle]pathForResource:@"Profes ...
- AngularJS学习小结
在刚学习AngularJS的时候觉得好像挺简单的,看见老师每次用很少的代码就做出用源生代码或者JQuery要用多行代码才做出的效果的时候觉得好像思路很简单,也很好写就写出来了,但是等到我们自己做的时候 ...