首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF SocketException

WCF SocketException
EN

Stack Overflow用户
提问于 2012-03-15 05:12:36
回答 2查看 2.4K关注 0票数 1

我正在用VS2010开发一个WCF应用程序。当我使用IDE内调试器运行宿主应用程序和客户端时,一切都正常工作。

但是,当我手动运行这两个可执行文件(转到/bin/Debug/文件夹)时,从客户端得到以下异常:

System.Net.Sockets.SocketException:无法建立连接,因为目标计算机主动拒绝它127.0.0.1:8732

奇怪的是,在我指定的app.config文件中使用端口5000,而不是8732。

怎么了?提前谢谢你。

编辑:以下是主机应用程序的app.config:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <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="WCFServiceLibrary.SavalotServiceObject">
        <endpoint address="" binding="wsHttpBinding" contract="WCFServiceLibrary.ISavalotService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:5000/Design_Time_Addresses/WCFServiceLibrary/SavalotServiceObject/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above 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>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-03-15 06:23:30

张贴,这样用户就不需要阅读13条评论

在这种情况下,问题是用户正在运行多项目解决方案。在这种情况下,无论哪个项目正在运行,都是其配置文件很重要的项目。

如果您正在 WcfService上运行,则需要包含服务的项目将其web.config文件配置为使用正确的端口。

如果您要对WcfService进行测试,则需要测试项目将其app.config文件配置为使用正确的端口。

这是webservices新手犯下的常见错误,没什么好丢脸的。

票数 4
EN

Stack Overflow用户

发布于 2012-03-15 05:15:12

你有没有试过使用像WireShark这样的东西?在两个端点上运行它是解决套接字问题的好方法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9710351

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档