连接时WCF异常

时间:2013-05-16 10:30:19

标签: c# wcf

我已将WPF应用程序添加到WCF类库,我在WCF中的App配置如下

  <service name="WCFChatApplication.Service1">
    <host>
      <baseAddresses>
        <add baseAddress = "http://localhost:8732/Design_Time_Addresses/WCFChatApplication/Service1/" />
      </baseAddresses>
    </host>
    <!-- Service Endpoints -->
    <!-- Unless fully qualified, address is relative to base address supplied above -->
    <endpoint address ="" binding="wsDualHttpBinding" contract="WCFChatApplication.IMessageServiceInbound">
      <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <!-- Metadata Endpoints -->
    <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
    <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>

我的WPF应用程序cpnfig是

    <bindings>
        <wsDualHttpBinding>
            <binding name="WSDualHttpBinding_IMessageServiceInbound" 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>

但是当我打电话时

 ServiceReference1.MessageServiceInboundClient Sc1 = new ServiceReference1.MessageServiceInboundClient(new InstanceContext(this),"WSDualHttpBinding_IMessageServiceInbound");
            Sc1.Open();

我得到的错误是

HTTP无法注册URLhttp:// +:80 / Temporary_Listen_Addresses / 9b1e11c2-0c91-43a6-9a17-26f473a9fdbc /因为另一个应用程序正在使用TCP端口80。

使用端口80的进程是Inetinfo.exe。我似乎无法完成此过程。

有没有办法可以从端口80移动到任何其他端口。

由于

3 个答案:

答案 0 :(得分:2)

您正在使用双工绑定,因此客户端必须设置服务器可以访问的地址。默认情况下,它似乎使用IIS正在使用的端口80。

将绑定的clientBaseAddress设置为另一个地址,你应该好好去。确保客户端可以从服务器访问该端口(防火墙,端口转发等)。

答案 1 :(得分:0)

我的猜测是Visual Studio正在尝试托管WCF服务,这会导致与您的应用程序完成的托管冲突。

打开WCF项目的属性。

打开WCF选项标签。

取消选中第一个复选框(在同一解决方案中调试另一个项目时启动WCF服务主机)

答案 2 :(得分:0)