2011-09-08 57 views
0

我有一個客戶端,它使用服務引用生成其app.config,通過本地主機上的NetTCPBinding。出於某種原因,當我在客戶端上運行我的服務並更新服務引用時,app.config文件將複製端點(遞增名稱)而不是替換當前文件。客戶端app.config生成重複的端點[WCF]

如何阻止客戶端app.config複製終結點?

這是我服務的app.config:

<services> 
    <service name="Embedded_DCC_Service.EmbeddedService" behaviorConfiguration="serviceBehavior"> 
     <endpoint 
     name ="TCPEndPoint" 
     binding="netTcpBinding" 
     contract="Embedded_DCC_Service.IEmbeddedService" 
     address="EmbeddedService" 
     bindingConfiguration="EmbeddedService_Binding" 
     /> 
     <endpoint 
     name ="MetaDataTcpEndpoint" 
     binding="mexTcpBinding" 
     contract="IMetadataExchange" 
     address="mex" 
     /> 
     <host> 
     <baseAddresses> 
      <add baseAddress="net.tcp://localhost:9292/"/> 
     </baseAddresses> 
     </host> 
    </service> 
    </services> 

    <bindings> 
    <netTcpBinding> 
     <binding name="EmbeddedService_Binding" closeTimeout="infinite" openTimeout="infinite" 
      receiveTimeout="infinite" sendTimeout="infinite" /> 
    </netTcpBinding> 
    </bindings> 

    <behaviors> 
    <serviceBehaviors> 
     <behavior name="serviceBehavior"> 
     <serviceMetadata httpGetEnabled="false"/> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 

</system.serviceModel> 

和客戶端上所產生的app.config(含重複的條目):

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
    <bindings> 
     <netTcpBinding> 
     <binding name="TCPEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00" 
      receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" 
      transferMode="Buffered" transactionProtocol="OleTransactions" 
      hostNameComparisonMode="StrongWildcard" listenBacklog="10" 
      maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" 
      maxReceivedMessageSize="65536"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
       maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00" 
       enabled="false" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"> 
       <extendedProtectionPolicy policyEnforcement="Never" /> 
      </transport> 
      <message clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     <binding name="TCPEndPoint1" closeTimeout="00:01:00" openTimeout="00:01:00" 
      receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" 
      transferMode="Buffered" transactionProtocol="OleTransactions" 
      hostNameComparisonMode="StrongWildcard" listenBacklog="10" 
      maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" 
      maxReceivedMessageSize="65536"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
       maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00" 
       enabled="false" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"> 
       <extendedProtectionPolicy policyEnforcement="Never" /> 
      </transport> 
      <message clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     <binding name="TCPEndPoint2" closeTimeout="00:01:00" openTimeout="00:01:00" 
      receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" 
      transferMode="Buffered" transactionProtocol="OleTransactions" 
      hostNameComparisonMode="StrongWildcard" listenBacklog="10" 
      maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" 
      maxReceivedMessageSize="65536"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
       maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00" 
       enabled="false" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"> 
       <extendedProtectionPolicy policyEnforcement="Never" /> 
      </transport> 
      <message clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     <binding name="TCPEndPoint3" closeTimeout="00:01:00" openTimeout="00:01:00" 
      receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" 
      transferMode="Buffered" transactionProtocol="OleTransactions" 
      hostNameComparisonMode="StrongWildcard" listenBacklog="10" 
      maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" 
      maxReceivedMessageSize="65536"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
       maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <reliableSession ordered="true" inactivityTimeout="00:10:00" 
       enabled="false" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"> 
       <extendedProtectionPolicy policyEnforcement="Never" /> 
      </transport> 
      <message clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    <client> 
     <endpoint address="net.tcp://localhost:9292/EmbeddedService" 
      binding="netTcpBinding" bindingConfiguration="TCPEndPoint" 
      contract="ServiceReference1.IEmbeddedService" name="TCPEndPoint"> 
     <identity> 
      <userPrincipalName value="[email protected]" /> 
     </identity> 
     </endpoint> 
     <endpoint address="net.tcp://localhost:9292/EmbeddedService" 
      binding="netTcpBinding" bindingConfiguration="TCPEndPoint1" 
      contract="ServiceReference1.IEmbeddedService" name="TCPEndPoint1"> 
     <identity> 
      <userPrincipalName value="[email protected]" /> 
     </identity> 
     </endpoint> 
     <endpoint address="net.tcp://localhost:9292/EmbeddedService" 
      binding="netTcpBinding" bindingConfiguration="TCPEndPoint2" 
      contract="ServiceReference1.IEmbeddedService" name="TCPEndPoint2"> 
     <identity> 
      <userPrincipalName value="[email protected]" /> 
     </identity> 
     </endpoint> 
     <endpoint address="net.tcp://localhost:9292/EmbeddedService" 
      binding="netTcpBinding" bindingConfiguration="TCPEndPoint3" 
      contract="ServiceReference1.IEmbeddedService" name="TCPEndPoint3"> 
     <identity> 
      <userPrincipalName value="[email protected]" /> 
     </identity> 
     </endpoint> 
    </client> 
    </system.serviceModel> 
</configuration> 

回答

0

看起來像你的問題是類似this問題

它告訴,這是在Visual Studio 2010中一個已知的bug,並告訴檢查這link

+0

是的,這看起來像問題!我使用VS2008,它似乎也有問題。 –

-1

您也可以嘗試綁定程序ically,像這樣(你將不得不改變按您選擇):

BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); 
       binding.Name = "ActivationManagerSoap"; 
       binding.CloseTimeout = new TimeSpan(0, 5, 0); 
       binding.OpenTimeout = new TimeSpan(0, 5, 0); 
       binding.ReceiveTimeout = new TimeSpan(0, 5, 0); 
       binding.SendTimeout = new TimeSpan(0, 5, 0); 
       binding.AllowCookies = false; 
       binding.BypassProxyOnLocal = false; 
       binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; 
       binding.MaxBufferSize = 65536; binding.MaxBufferPoolSize = 524288; 
       binding.MaxReceivedMessageSize = 65536; 
       binding.MessageEncoding = WSMessageEncoding.Text; 
       binding.TextEncoding = Encoding.UTF8; 
       binding.TransferMode = TransferMode.Buffered; 

       binding.UseDefaultWebProxy = true; 
       XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas(); 
       quotas.MaxDepth = 32; 
       quotas.MaxStringContentLength = 8192; 
       quotas.MaxArrayLength = 16384; 
       quotas.MaxBytesPerRead = 4096; 
       quotas.MaxNameTableCharCount = 16384; 
       binding.ReaderQuotas = quotas; 


       EndpointAddress addres = new EndpointAddress("http://xxxxxx/service"); 

       ActivationService.ActivationManagerSoapClient client = new ActivationService.ActivationManagerSoapClient(binding, addres); 
+0

感謝信息Parvesh,但這並沒有真正回答這個問題。 –

+0

對不起並不直接回答你的問題,只是一種替代方式。 – Parvesh

+0

這是有價值的信息,我會利用它。謝謝。 –