Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.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服务时出现此错误_C#_.net_Wcf_Windows Services - Fatal编程技术网

C# 为什么在尝试连接到WCF服务时出现此错误

C# 为什么在尝试连接到WCF服务时出现此错误,c#,.net,wcf,windows-services,C#,.net,Wcf,Windows Services,我在一台计算机上的windows服务中托管了一个WCF服务,在另一台计算机上有另一个windows服务作为客户端连接到第一台计算机上的WCF服务。我猜这和安全有关,但我不知道该怎么办。以下是客户端的app.config: The caller was not authenticated by the service. 以及服务的app.config: <system.serviceModel> <bindings> <wsDualHtt

我在一台计算机上的windows服务中托管了一个WCF服务,在另一台计算机上有另一个windows服务作为客户端连接到第一台计算机上的WCF服务。我猜这和安全有关,但我不知道该怎么办。以下是客户端的app.config:

The caller was not authenticated by the service.

以及服务的app.config:

<system.serviceModel>
    <bindings>
        <wsDualHttpBinding>
            <binding name="WSDualHttpBinding_IWCFService" closeTimeout="00:01:00" 
                     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
                     bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
                     maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
                     messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
                              maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
                <reliableSession ordered="true" inactivityTimeout="00:10:00"/>
                <security mode="Message">
                    <message clientCredentialType="Windows" negotiateServiceCredential="true" 
                             algorithmSuite="Default"/>
                </security>
            </binding>
        </wsDualHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" 
                  binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IWCFService" 
                  contract="WCFService.IWCFService" name="WSDualHttpBinding_IWCFService">
            <identity>
                <dns value="localhost"/>
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

我需要做什么才能连接到我的WCF服务


另一件需要注意的事情是,我创建了一个简单的控制台应用程序作为wcf服务的客户端,它能够毫无问题地连接到该服务,并且app.config文件看起来完全相同。也许is与作为不同用户运行的客户端服务有关?我可以删除任何和所有安全性,但不知道如何删除。

控制台应用程序可能正在使用您的凭据运行,无法连接wcf服务的Windows服务可能正在使用本地系统帐户运行。尝试使用身份验证模式“用户”和您的凭据安装服务。请执行以下两项操作:检查上述标识,确保您的其他服务不是以本地用户(默认设置!例如NetworkService)的身份运行,而是以域用户的身份运行,或者重新考虑您的设置(如果您在域中获得了所需的权限,您可以通过在您的帐户下运行服务来测试这一点)

不要这样做-您可以随时用其他帐户信息覆盖已安装的服务,但将您的凭据放在文本文件中可能不是最好的主意!当员工离开公司且其帐户被停用时,这是一种确定问题来源的测试
<system.serviceModel>
<services>
  <service name="WCF.WCFService" behaviorConfiguration="WCFBehavior">
    <endpoint address="" binding="wsDualHttpBinding" contract="WCF.IWCFService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint
      address="mex"
      binding="mexHttpBinding"
      bindingConfiguration=""
      contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="WCFBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>