2013-05-16 78 views
2

我已經添加了WPF應用WCF類庫和WCF我的應用程序配置如下同時連接

<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> 

但WCF異常,當我打電話

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.I似乎無法關閉此過程。

有沒有一種方法可以從端口80移動到任何其他端口。

感謝

+2

您如何/在哪裏託管服務? –

+0

我正在做selfhosting – Rohit

回答

2

您使用的是雙螺旋結合,以便客戶機具有設置一個地址,其中服務器可以達到它。默認情況下,它似乎使用由IIS使用的端口80。

將綁定的clientBaseAddress設置爲另一個地址,你應該很好。確保端口可以從服務器上訪問客戶端(防火牆,端口轉發等)。

+1

啊,我沒有注意到。接得好! –

+0

當我嘗試更改基地址如http:// localhost:445/Design_Time_Addresses/WCFChatApplication/Service1 /時,WCF拋出錯誤,請嘗試將HTTP端口更改爲8732或以管理員身份運行。 System.ServiceModel.AddressAccessDeniedException:HTTP無法註冊URL http:// +:445/Design_Time_Addresses/WCFChatApplication/Service1 /。您的進程無權訪問此名稱空間(有關詳細信息,請參閱http://go.microsoft.com/fwlink/?LinkId=70353)。 ---> System.Net.HttpListenerException:訪問被拒絕 – Rohit

+0

@Kyle然後做錯誤說。 – CodeCaster

0

我的猜測是,Visual Studio是試圖舉辦WCF服務,這會導致你的應用程序進行託管的衝突。

打開WCF項目的屬性。

打開WCF選項選項卡。

取消選中第一個複選框(開始WCF服務主機調試在同一個解決方案的另一個項目時)