公司的項目,由於老項目裡面使用的是.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
上網找了下,只要把設定檔中的一段注釋掉就行了,見下面代碼
設定檔如下:
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>