C# 访问WCF服务时发生异常,指定的域不存在或无法联系

C# 访问WCF服务时发生异常,指定的域不存在或无法联系,c#,.net,winforms,wcf,web-services,C#,.net,Winforms,Wcf,Web Services,我正在运行由Windows窗体客户端使用的WCF服务。我正在服务器上使用Windows身份验证,WCF服务工作正常。服务中实现的所有功能在客户端应用程序上都可以正常工作,只有一个功能除外。我检查了该函数的[DataContract]和[OperationContract]的服务代码,甚至使用SvcLogViewer.exe检查了Svc日志。但函数不断引发NullReferenceException。我在SvcLog中发现的异常是 The specified domain either does

我正在运行由Windows窗体客户端使用的WCF服务。我正在服务器上使用Windows身份验证,WCF服务工作正常。服务中实现的所有功能在客户端应用程序上都可以正常工作,只有一个功能除外。我检查了该函数的
[DataContract]
[OperationContract]
的服务代码,甚至使用SvcLogViewer.exe检查了Svc日志。但函数不断引发
NullReferenceException
。我在SvcLog中发现的异常是

The specified domain either does not exist or could not be contacted
此功能在本地服务器上运行正常,但在远程服务器上运行不正常。我想知道的是发生此异常的原因,以下是我的ServiceModel代码:

<system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="Wrabind" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:25:00">
          <textMessageEncoding/>
          <security authenticationMode="SecureConversation" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
            <localClientSettings maxClockSkew="00:30:00" />
            <localServiceSettings maxClockSkew="00:30:00" />
            <secureConversationBootstrap messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
              <localClientSettings maxClockSkew="00:30:00" />
              <localServiceSettings maxClockSkew="00:30:00" />
            </secureConversationBootstrap>
          </security>
          <httpTransport maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000" allowCookies="true" maxBufferSize="20000000" />
        </binding>
      </customBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="WCoreService.Service1Behavior" name="WCoreService.Service1">
        <endpoint address="http://subdomain.domain.com/service1.svc" binding="customBinding" bindingConfiguration="Wrabind" contract="WCoreService.IService1" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WCoreService.Service1Behavior">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment>
      <baseAddressPrefixFilters>
        <add prefix="http://subdomain.domain.com/" />
      </baseAddressPrefixFilters>
    </serviceHostingEnvironment>

  </system.serviceModel>

最后我自己解决了。代码中有一些逻辑错误,我找不到,但不知怎的,通过整个控制流,我发现了那个小错误。错误实际上是,在客户端,我在一个尚未创建服务连接的地方调用错误的服务函数。它是在代码的后面创建的。因此,我只是将调用之前的连接创建代码转移到了错误的服务函数,它成功了。我希望有同样问题的人会发现这个解决方案很有用