出现问题的原因

在本机上没有出现问题,让一个同事测试的时候,在另外一台电脑上出现连接数据库失败,系统不能打开的问题


在网上搜了一下,有说是数据库连接字符串错误的,有说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替换。

另:

还有人给出这样的解决方法,没有试过,各位遇到这种问题可以自己试一下是否可行

最新文章

  1. 数据结构:顺序表(python版)
  2. 《企业应用架构模式》(POEAA)读书笔记
  3. ASP.NET的编译原理
  4. 使用apache.lang包安全简洁地操作Java时间
  5. 初探 Ext JS 6 (sencha touch/ext升级版)
  6. cocos2dx3.0-tinyxml在Android环境下解析xml失败的问题
  7. UVA 658 It&#39;s not a Bug, it&#39;s a Feature!
  8. python学习之旅:array 转 list
  9. Error creating bean with name &amp;#39;com.you.user.dao.StudentDaoTest&amp;#39;: Injection of autowired dependencies
  10. python练习题一
  11. HTML语言笔记
  12. 基于JavaBean编辑器读取peroperties文件
  13. JAVA中使用log4j及slf4j进行日志输出的方法详解
  14. 分析 ajax 请求并抓取今日头条街拍美图
  15. Springboot 生成验证码
  16. ksort 函数
  17. rpm使用
  18. go语言使用go-sciter创建桌面应用(三) 事件处理,函数与方法定义,go与tiscript之间相互调用
  19. [Go] panic 和 recover
  20. JavaScript DOM大纲

热门文章

  1. 代码片段---S3C2440按键中断驱动程序的设计
  2. iOS 开发之— NSURLProtocol
  3. [super dealloc]内存释放的先后顺序
  4. UISegmentedControl 分段器加载不同的viewcontroller
  5. makefile文件的技术
  6. XML 命名空间
  7. 不错的jQuery图表插件 .
  8. 如何解决firefox下window.event的问题
  9. 正则转nfa:bug出现。
  10. Android微信支付SDK开发笔记