2014-03-28 145 views
0

我無法弄清楚這一點。這段代碼已經完美地執行了很長一段時間,現在它無處不在。它所調用的網絡服務並沒有改變,我有點茫然。特定的錯誤是我使用{"Configuration system failed to initialize"}Web服務拋出錯誤

代碼:

webservices.WebService ws = new webservices.WebService(); 

代碼的設計師

namespace NumberOneService.Properties { 

[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 

    private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 

    public static Settings Default { 
     get { 
      return defaultInstance; 
     } 
    } 

    [global::System.Configuration.ApplicationScopedSettingAttribute()] 
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
    [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)] 
    [global::System.Configuration.DefaultSettingValueAttribute("http://www.webserver.services/ws_partlookup.cfc")] 
    public string Web_Service { 
     get { 
      return ((string)(this["Web_Service"])); 
     } 
    } 
} 

堆棧跟蹤:

at System.Configuration.ClientConfigurationSystem.OnConfigRemoved(Object sender, InternalConfigEventArgs e) 
    at System.Configuration.Internal.InternalConfigRoot.RemoveConfigImpl(String configPath, BaseConfigurationRecord configRecord) 
    at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) 
    at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) 
    at System.Configuration.ConfigurationManager.GetSection(String sectionName) 
    at System.Configuration.ClientSettingsStore.ReadSettings(String sectionName, Boolean isUserScoped) 
    at System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext context, SettingsPropertyCollection properties) 
    at System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider) 
    at System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName) 
    at System.Configuration.SettingsBase.get_Item(String propertyName) 
    at System.Configuration.ApplicationSettingsBase.GetPropertyValue(String propertyName) 
    at System.Configuration.ApplicationSettingsBase.get_Item(String propertyName) 
    at NumberOneService.Properties.Settings.get_Web_Service() in Number One Service\Properties\Settings.Designer.cs:line 33 
    at NumberOneService.webservices.WebService..ctor() in Number One Service\Web References\webservices\Reference.cs:line 46 
    at NumberOneService.NumberOneService.bwExecuteProcess_DoWork(Object sender, DoWorkEventArgs e) in Number One Service.cs:line 400 
    at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument) 

回答

0

如果您創建這通常發生一個類庫中的Web服務引用,然後將其移植到控制檯應用程序或獲勝dows應用程序。 Web服務引用以特定路徑存儲在設置文件中。

基本上,你缺少一個部分聲明或配置文件中正確的設置名稱。 請檢查您的配置文件中存儲該服務的URL的密鑰。否則,粘貼在這裏,我們可以進一步幫助。

當它試圖從配置文件中設置Url時,web服務構造函數中會引發異常。 (主機配置或設置文件)