Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.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 windows服务_C#_Wcf_Windows Services - Fatal编程技术网

C# 从另一台电脑消费WCF windows服务

C# 从另一台电脑消费WCF windows服务,c#,wcf,windows-services,C#,Wcf,Windows Services,我创建了一个WCF服务,并将其托管在windows服务中。使用VisualStudio测试此服务效果很好,我可以使用它。现在我已经在一台PC(称为PC1)上安装了这项服务,并且使用另一台PC(称为PC2),我希望能够发现它并使用它。我想我必须修改app.config文件才能实现这一点 这是我当前的app.config,我需要修改什么才能从其他联网计算机上运行它?我猜基址是个开始 <?xml version="1.0" encoding="utf-8" ?> <configura

我创建了一个WCF服务,并将其托管在windows服务中。使用VisualStudio测试此服务效果很好,我可以使用它。现在我已经在一台PC(称为PC1)上安装了这项服务,并且使用另一台PC(称为PC2),我希望能够发现它并使用它。我想我必须修改app.config文件才能实现这一点

这是我当前的app.config,我需要修改什么才能从其他联网计算机上运行它?我猜基址是个开始

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<appSettings>
  <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
  <compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
  <services>      
  <service name="WcfAVOLibrary.AVOs">
    <endpoint address="" binding="wsDualHttpBinding" contract="WcfAVOLibrary.IAVOs">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8733/Design_Time_Addresses/WcfAVOLibrary/AVOs/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="True"/>
      <!-- To receive exception details in faults for debugging purposes, 
      set the value below to true.  Set to false before deployment 
      to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

哦,我正在运行.NET4.5
  • (如果未实现web服务,我建议使用此链接 )
  • 您应该尝试在以下位置修改web.config:

      <baseAddresses>
        <add baseAddress="http://192.168.1.2/Design_Time_Addresses/WcfAVOLibrary/AVOs/" />
      </baseAddresses>
    
    
    
    如果192.168.1.2是您当前的ip,或者localhost也可以工作,那么它将如下所示:

      <baseAddresses>
        <add baseAddress="http://localhost/Design_Time_Addresses/WcfAVOLibrary/AVOs/" />
      </baseAddresses>
    

    首先,通过pc1在基址上更改localhost,如

    http://pc1:8733/Design_Time_Addresses/WcfAVOLibrary/AVOs/

    之后,尝试从pc2上的浏览器打开基本地址url(是的,不要介意它是win.service-这是您的服务url,应该可以访问)。这应该是好的,你不需要继续之前,你得到它的工作


    完成后-查看客户端配置以匹配服务地址。

    也面临同样的问题。添加了入站规则以在Windows防火墙中打开端口8733。成功了

    这是windows服务而不是web服务我在另一台电脑上尝试了该地址,但无法使其正常工作。