Web服务投掷错误

时间:2014-03-28 20:13:52

标签: c# web-services properties

我无法想出这个。这段代码已经完美执行了很长一段时间,现在无处不在。它所称的网络服务没有改变,我有点不知所措。具体错误为{"Configuration system failed to initialize"}

代码I使用:

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)

1 个答案:

答案 0 :(得分:0)

如果您在类库中创建了Web服务引用,然后将其移植到控制台应用程序或Windows应用程序,则通常会发生这种情况。 Web服务引用存储在具有特定路径的设置文件中。

基本上,您在配置文件中缺少部分声明或正确的设置名称。 请检查您的配置文件以获取存储服务网址的密钥。否则,请将其粘贴在此处,我们可以进一步提供帮助。

当Web服务构造函数尝试从配置文件中设置Url时,会抛出异常。 (主机配置或设置文件)