公司的项目,由于老项目里面使用的是.net framework 2.0环境,而我们开发使用的却是VS2008,所以在创建新的应用的时候,把环境设置为.net frameword2.0。
这是一个客户端界面程序,应用到web服务。
但在运行的时候出现以下错误:
Code
2008 - 11 - 18 18 : 36 : 44 , 093 [ 352 ] DEBUG UTrial.YHDClient.MainForm [( null )] < ( null ) > - System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section system.serviceModel. (D:\CMI\TMSEXE\YHDClient.exe.Config line 8 )
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
--- End of inner exception stack trace ---
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Xml.Serialization.XmlSerializerCompilerParameters.Create(String location)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
at *** .CMIService.CMIClientService..ctor() in D:\CMI\TMSEXE\Web References\CMIService\Reference.cs:line 97
at *** .MainForm.Login() in D:\CMI\TMSEXE\form\MainForm.cs:line 67
2008 - 11 - 18 18 : 36 : 44 , 093 [ 352 ] DEBUG UTrial.YHDClient.MainForm [( null )] < ( null ) > - System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section system.serviceModel. (D:\CMI\TMSEXE\YHDClient.exe.Config line 8 )
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
--- End of inner exception stack trace ---
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Xml.Serialization.XmlSerializerCompilerParameters.Create(String location)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
at *** .CMIService.CMIClientService..ctor() in D:\CMI\TMSEXE\Web References\CMIService\Reference.cs:line 97
at *** .MainForm.Login() in D:\CMI\TMSEXE\form\MainForm.cs:line 67
上网找了下,只要把配置文件中的一段注释掉就行了,见下面代码
配置文件如下:
Code
<? 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 = " ***.Properties.Settings " type = " System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 " requirePermission = " false " />
</ sectionGroup >
</ configSections >
<!-- 这一段要注释掉
< system.serviceModel >
< bindings />
< client />
</ system.serviceModel >
-->
< applicationSettings >
<*** .Properties.Settings >
< setting name = " **** "
serializeAs = " String " >
< value > http: // www.****.com/***Service.asmx</value>
</ setting >
< /* **.Properties.Settings>
</applicationSettings>
</configuration>
<? 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 = " ***.Properties.Settings " type = " System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 " requirePermission = " false " />
</ sectionGroup >
</ configSections >
<!-- 这一段要注释掉
< system.serviceModel >
< bindings />
< client />
</ system.serviceModel >
-->
< applicationSettings >
<*** .Properties.Settings >
< setting name = " **** "
serializeAs = " String " >
< value > http: // www.****.com/***Service.asmx</value>
</ setting >
< /* **.Properties.Settings>
</applicationSettings>
</configuration>
更多文章、技术交流、商务合作、联系博主
微信扫码或搜索:z360901061
微信扫一扫加我为好友
QQ号联系: 360901061
您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。
【本文对您有帮助就好】元