排查错误,问自己几个问题:1. 服务以前好使么?(错误是最近修改什么配置导致的么?)
2. 服务IP,在错误发生机器上是否可以ping通?
3. 服务端口,通过telnet是否可以连接?

解决方案 »

  1.   

    配置错误就发服务器端的web.config配置信息出来,你发这个信息出来对解决你的这个问题用处不大
      

  2.   

    服务端的配置主要<service><Banding><Behaves>,其次就是接口
      

  3.   

    <?xml version="1.0"?>
    <configuration>
      <system.serviceModel>
        <diagnostics wmiProviderEnabled="false" performanceCounters="Off">
          <messageLogging logMalformedMessages="false" logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="false"/>
        </diagnostics>
        <behaviors>
          <serviceBehaviors>
            <behavior name="IdcServiceBehavior">
              <serviceMetadata httpGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="true"/>
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
          <wsHttpBinding>
            <binding name="NoneSecurity" maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false">
              <readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/>
              <security mode="None"/>
            </binding>
          </wsHttpBinding>
        </bindings>
        <services>
          <service behaviorConfiguration="IdcServiceBehavior" name="Deepleo.IDC.Server.Services.AdminService">
            <endpoint binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="Deepleo.IDC.Contract.IAdminService" listenUriMode="Explicit"></endpoint>
            <host>
              <baseAddresses>
                <!--<add baseAddress="http://1127.0.0.1:6523/AdminService" />-->
                <add baseAddress="http://127.0.0.1:6523/AdminService"/>
              </baseAddresses>
            </host>
          </service>
          <service behaviorConfiguration="IdcServiceBehavior" name="Deepleo.IDC.Server.Services.IdcService">
            <endpoint binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="Deepleo.IDC.Contract.IIdcService" listenUriMode="Explicit"></endpoint>
            <host>
              <baseAddresses>
                <!--<add baseAddress="http://1127.0.0.1:6523/IdcService" />-->
                <add baseAddress="http://127.0.0.1:6523/IdcService"/>
              </baseAddresses>
            </host>
          </service>
          <service behaviorConfiguration="IdcServiceBehavior" name="Deepleo.IDC.Server.Services.LogService">
            <endpoint binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="Deepleo.IDC.Contract.ILogService" listenUriMode="Explicit"></endpoint>
            <host>
              <baseAddresses>
                <!--<add baseAddress="http://1127.0.0.1:6523/LogService" />-->
                <add baseAddress="http://127.0.0.1:6523/LogService"/>
              </baseAddresses>
            </host>
          </service>      <service behaviorConfiguration="IdcServiceBehavior" name="Deepleo.IDC.Server.Services.SettingsService">
            <endpoint binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="Deepleo.IDC.Contract.ISettingsService" listenUriMode="Explicit"></endpoint>
            <host>
              <baseAddresses>
                <!--<add baseAddress="http://1127.0.0.1:6523/SettingsService" />-->
                <add baseAddress="http://127.0.0.1:6523/SettingsService"/>
              </baseAddresses>
            </host>
          </service>
          <service behaviorConfiguration="IdcServiceBehavior" name="Deepleo.IDC.Server.Services.SyncClientDataService">
            <endpoint binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="Deepleo.IDC.Contract.ISyncClientDataService" listenUriMode="Explicit"></endpoint>
            <host>
              <baseAddresses>
                <!--<add baseAddress="http://1127.0.0.1:6523/SyncClientDataService" />-->
                <add baseAddress="http://127.0.0.1:6523/SyncClientDataService"/>
              </baseAddresses>
            </host>
          </service>
        </services>  </system.serviceModel>  <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" sku = ".NETFramework,Version=v4.0"/>
        <supportedRuntime version="v2.0.50727"/>
      </startup>
    </configuration>
      

  4.   

    这些都试过了没问题,就是在设置客户端对应服务端的IP的时候就出现这样的错!配置文件的问题有关调用实时(JIT)调试而不是此对话框的详细信息,
    请参见此消息的结尾。************** 异常文本 **************
    System.Configuration.ConfigurationErrorsException: 配置系统未能初始化 ---> System.Configuration.ConfigurationErrorsException: 给定编码中的字符无效。 第 9 行,位置 63。 (D:\IDCorder20131217\UI\bin\Debug\Deepleo.IDC.Client.exe.Config line 9) ---> System.Xml.XmlException: 给定编码中的字符无效。 第 9 行,位置 63。
       在 System.Xml.XmlTextReaderImpl.Throw(Exception e)
       在 System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
       在 System.Xml.XmlTextReaderImpl.InvalidCharRecovery(Int32& bytesCount, Int32& charsCount)
       在 System.Xml.XmlTextReaderImpl.GetChars(Int32 maxCharsCount)
       在 System.Xml.XmlTextReaderImpl.ReadData()
       在 System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
       在 System.Xml.XmlTextReaderImpl.ParseAttributes()
       在 System.Xml.XmlTextReaderImpl.ParseElement()
       在 System.Xml.XmlTextReaderImpl.ParseElementContent()
       在 System.Xml.XmlTextReaderImpl.Read()
       在 System.Xml.XmlTextReader.Read()
       在 System.Configuration.XmlUtil.CopyXmlNode(XmlUtilWriter utilWriter)
       在 System.Configuration.XmlUtil.CopyElement(XmlUtilWriter utilWriter)
       在 System.Configuration.XmlUtil.CopySection()
       在 System.Configuration.BaseConfigurationRecord.ScanSectionsRecursive(XmlUtil xmlUtil, String parentConfigKey, Boolean inLocation, String locationSubPath, OverrideModeSetting overrideMode, Boolean skipInChildApps)
       在 System.Configuration.BaseConfigurationRecord.ScanSections(XmlUtil xmlUtil)
       在 System.Configuration.BaseConfigurationRecord.InitConfigFromFile()
       --- 内部异常堆栈跟踪的结尾 ---
       在 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()
       在 Deepleo.IDC.Client.GlobalSettings.Init() 位置 D:\IDCorder20131217\UI\GlobalSettings.cs:行号 46
       在 Deepleo.IDC.Client.FormLogin.FormLogin_Load(Object sender, EventArgs e) 位置 D:\IDCorder20131217\UI\FormLogin.cs:行号 73
       在 System.EventHandler.Invoke(Object sender, EventArgs e)
       在 System.Windows.Forms.Form.OnLoad(EventArgs e)
       在 System.Windows.Forms.Form.OnCreateControl()
       在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       在 System.Windows.Forms.Control.CreateControl()
       在 System.Windows.Forms.Control.WmShowWindow(Message& m)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       在 System.Windows.Forms.Form.WmShowWindow(Message& m)
       在 System.Windows.Forms.Form.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    ************** 已加载的程序集 **************
    mscorlib
        程序集版本: 4.0.0.0
        Win32 版本: 4.0.30319.1008 (RTMGDR.030319-1000)
        基本代码: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    ----------------------------------------
    Deepleo.IDC.Client
        程序集版本: 1.0.0.0
        Win32 版本: 1.0.0.0
        基本代码: file:///D:/IDCorder20131217/UI/bin/Debug/Deepleo.IDC.Client.exe
    ----------------------------------------
    System.Windows.Forms
        程序集版本: 4.0.0.0
        Win32 版本: 4.0.30319.1002 built by: RTMGDR
        基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
        程序集版本: 4.0.0.0
        Win32 版本: 4.0.30319.1001 built by: RTMGDR
        基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System
        程序集版本: 4.0.0.0
        Win32 版本: 4.0.30319.1001 built by: RTMGDR
        基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    log4net
        程序集版本: 1.2.10.0
        Win32 版本: 1.2.10.0
        基本代码: file:///D:/IDCorder20131217/UI/bin/Debug/log4net.DLL
    ----------------------------------------
    System.Configuration
        程序集版本: 4.0.0.0
        Win32 版本: 4.0.30319.1015 (RTMGDR.030319-1000)
        基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    ----------------------------------------
    System.Xml
        程序集版本: 4.0.0.0
        Win32 版本: 4.0.30319.1015 built by: RTMGDR
        基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    mscorlib.resources
        程序集版本: 4.0.0.0
        Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
        基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/mscorlib.resources.dll
    ----------------------------------------
    System.xml.resources
        程序集版本: 4.0.0.0
        Win32 版本: 4.0.30319.1 built by: RTMRel
        基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/System.Xml.resources.dll
    ----------------------------------------
    System.Configuration.resources
        程序集版本: 4.0.0.0
        Win32 版本: 4.0.30319.1 (RTMRel.030319-0100)
        基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration.resources/v4.0_4.0.0.0_zh-Hans_b03f5f7f11d50a3a/System.Configuration.resources.dll
    ----------------------------------------
    Deepleo.IDC.Library
        程序集版本: 1.0.0.0
        Win32 版本: 1.0.0.0
        基本代码: file:///D:/IDCorder20131217/UI/bin/Debug/Deepleo.IDC.Library.DLL
    ----------------------------------------
    System.Windows.Forms.resources
        程序集版本: 4.0.0.0
        Win32 版本: 4.0.30319.1 built by: RTMRel
        基本代码: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_zh-Hans_b77a5c561934e089/System.Windows.Forms.resources.dll
    ----------------------------------------************** JIT 调试 **************
    要启用实时(JIT)调试,
    该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置
    jitDebugging 值。
    编译应用程序时还必须启用
    调试。例如: <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>启用 JIT 调试后,任何未经处理的异常
    都将被发送到在此计算机上注册的 JIT 调试器,
    而不是由此对话框处理。谢谢大神
      

  5.   

    那就是 xml 格式不正确了。贴出你的配置文件。
      

  6.   

    <?xml version="1.0"?>
    <configuration>
      <appSettings>
        <add key="SoftwareName" value="深圳鼎峰科技有限公司管理系统 demo"/>
        <add key="DataConnectionString" value="C:\Program Files (x86)\深圳鼎峰科技有限公司\深圳鼎峰Idc信息管理系统\IdcData.s3db;Pooling=true;FailIfMissing=false;Version=3"/>
      </appSettings>
      <system.serviceModel>
        <bindings>
          <wsHttpBinding>
            <binding name="NoneSecurity" maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false">
              <readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/>
              <security mode="None"/>
            </binding>
          </wsHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://127.0.0.1:6523/AdminService" binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="AdminServiceReference.IAdminService" name="WSHttpBinding_IAdminService">
            <identity/>
          </endpoint>
          <endpoint address="http://127.0.0.1:6523/IdcService" binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="IdcServiceReference.IIdcService" name="WSHttpBinding_IIdcService">
            <identity/>
          </endpoint>
          <endpoint address="http://127.0.0.1:6523/LogService" binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="LogServiceReference.ILogService" name="WSHttpBinding_ILogService">
            <identity/>
          </endpoint>
          <endpoint address="http://127.0.0.1:6523/SettingsService" binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="SettingsServiceReference.ISettingsService" name="WSHttpBinding_ISettingsService">
            <identity/>
          </endpoint>
          <endpoint address="http://127.0.0.1:6523/SyncClientDataService" binding="wsHttpBinding" bindingConfiguration="NoneSecurity" contract="SyncClientDataServiceReference.ISyncClientDataService" name="WSHttpBinding_ISyncClientDataService">
            <identity/>
          </endpoint>
        </client>
      </system.serviceModel>
      <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" sku = ".NETFramework,Version=v4.0"/>
        <supportedRuntime version="v2.0.50727"/>
      </startup>
    </configuration>
      

  7.   

    将你的xml文件另存为utf8编码的,当前编码下面有操作系统无法识别的字体。
      

  8.   

    我觉得可能是别的原因。看你的错误提示: 在 System.Configuration.ConfigurationManager.get_AppSettings()
       在 Deepleo.IDC.Client.GlobalSettings.Init() 位置 D:\IDCorder20131217\UI\GlobalSettings.cs:行号 46
       在 Deepleo.IDC.Client.FormLogin.FormLogin_Load(Object sender, EventArgs e) 位置 D:\IDCorder20131217\UI\FormLogin.cs:行号 73
    是取 AppSettings 时抛出的错误!
      

  9.   

    我仔细检查了一下,看来还是编码问题    //
            // 摘要:
            //     获取操作系统的当前 ANSI 代码页的编码。
            //
            // 返回结果:
            //     操作系统的当前 ANSI 代码页的编码。
            public static Encoding Default { get; }
    把配置文件改成UTF-8都行了。 挺纠结的 以前重没出现过这样的状况,不过也谢谢你们