Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WCF服务器和客户端之间通过LAN的通信失败_C#_.net_Windows_Wcf - Fatal编程技术网

C# WCF服务器和客户端之间通过LAN的通信失败

C# WCF服务器和客户端之间通过LAN的通信失败,c#,.net,windows,wcf,C#,.net,Windows,Wcf,我正在尝试在客户端和服务器之间进行通信,这是用C语言中的MicrosoftWCF-netTcpBinding创建的,服务器作为Windows服务运行。服务器作为一台PC在我的虚拟LAN上运行。但通信始终失败,出现错误: An unhandled exception of type 'System.ServiceModel.Security.SecurityNegotiationException' occurred in mscorlib.dll Additional information:

我正在尝试在客户端和服务器之间进行通信,这是用C语言中的MicrosoftWCF-netTcpBinding创建的,服务器作为Windows服务运行。服务器作为一台PC在我的虚拟LAN上运行。但通信始终失败,出现错误:

An unhandled exception of type 'System.ServiceModel.Security.SecurityNegotiationException' occurred in mscorlib.dll

Additional information: The server has rejected the client credentials.
在本地主机上,所有操作都正常工作。客户端也从该IP地址下载ServiceReference

服务器app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WCFHostService.MyServiceBehavior">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="WCFHostService.MyServiceBehavior" name="WCFServiceHost.MyService">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
              name="NetTcpBindingEndpoint" contract="WCFServiceHost.IMyService">
          <identity>
            <dns value="" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
            name="MexTcpBindingEndpoint" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://10.0.0.1:8523/WCFTestService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name = "netTcpBinding">
          <security mode="None"/>
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBindingEndpoint" />
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://10.0.0.1:8523/WCFTestService" binding="netTcpBinding"
                bindingConfiguration="NetTcpBindingEndpoint" contract="ServiceReference1.IMyService"
                name="NetTcpBindingEndpoint">
                <identity>
                    <dns value="&#xD;&#xA;          " />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>
客户端App.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WCFHostService.MyServiceBehavior">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="WCFHostService.MyServiceBehavior" name="WCFServiceHost.MyService">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
              name="NetTcpBindingEndpoint" contract="WCFServiceHost.IMyService">
          <identity>
            <dns value="" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
            name="MexTcpBindingEndpoint" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://10.0.0.1:8523/WCFTestService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name = "netTcpBinding">
          <security mode="None"/>
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBindingEndpoint" />
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://10.0.0.1:8523/WCFTestService" binding="netTcpBinding"
                bindingConfiguration="NetTcpBindingEndpoint" contract="ServiceReference1.IMyService"
                name="NetTcpBindingEndpoint">
                <identity>
                    <dns value="&#xD;&#xA;          " />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>
我认为问题可能出在配置文件中的安全设置上。请问那里怎么了?因为在服务器系统上的TCPView中,我看到MyService的远程地址只有他的本地计算机名,而不是全部。谢谢你的回复