2012-03-14 13 views
0

wcfサービスホストを準備し、以下のバインディング情報を使用して構成しました。サービス参照を追加してWCFホスト構成をクライアントに取得できません

<system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    <standardEndpoints> 
    <webHttpEndpoint> 
    <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" /> 
    </webHttpEndpoint> 
    </standardEndpoints> 
    <bindings> 
    <netTcpBinding> 
    <binding name="NetTcpBinding" closeTimeout="00:02:00" openTimeout="00:02:00" 
     receiveTimeout="00:20:00" sendTimeout="00:02:00" transactionFlow="true" 
     transferMode="Buffered" maxBufferPoolSize="2147483647" 
     maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> 
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
     maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
     maxNameTableCharCount="2147483647" /> 
     <security mode="None"> 
     <transport protectionLevel="None" /> 
     </security> 
    </binding> 
    </netTcpBinding> 
    </bindings> 
    <behaviors> 
    <serviceBehaviors> 
    <behavior name="tcpServiceBehavior"> 
     <serviceMetadata httpGetEnabled="false" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior> 
    </serviceBehaviors> 
    </behaviors> 
    <services> 
    <service behaviorConfiguration="tcpServiceBehavior" name="MyClass"> 
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcpBinding" contract="IMyClass"> 
     <identity> 
     <dns value="localhost" /> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="net.tcp://localhost:8732/Design_Time_Addresses/MyService/MyClass" /> 
     </baseAddresses> 
    </host> 
    </service> 
    </services> 
</system.serviceModel> 

、以下のコードでインスタンス化:[クイックウォッチを使用して

ServiceHost wcfHost = new ServiceHost(typeof(MyClass)); 
wcfHost.Open(); 

はそれをチェックアウトし、設定値を確認しました。次に、 "net.tcp:// localhost:8732/Design_Time_Addresses/MyService/MyClass"のサービスリファレンスを他のプロジェクトに追加しました。したがって、以下の新しい設定ファイルがクライアントプロジェクトに作成されました。

<system.serviceModel> 
    <bindings> 
    <netTcpBinding> 
     <binding name="NetTcpBinding_IMyClass" 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="None"> 
      <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
      <message clientCredentialType="Windows" /> 
     </security> 
     </binding> 
    </netTcpBinding> 
    </bindings> 
    <client> 
    <endpoint address="net.tcp://localhost:8732/Design_Time_Addresses/MyService/MyClass" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyClass" contract="IMyClass" name="NetTcpBinding_IMyClass"> 
     <identity> 
     <dns value="localhost" /> 
     </identity> 
    </endpoint> 
    </client> 
</system.serviceModel> 

問題は、ホストのバインディング設定がクライアントに送信されないことです。クライアントの設定を変更しても、影響はありません。たとえば、maxStringContentLength値をから8192からに変更した場合、クライアントは正しい設定でインスタンス化されていますが、古い設定で動作していました。ソリューション内で ""を検索しました。.svcinfoファイルがXMLスキームとして見つかりました。どのように私はこの奇妙な状況を解決することができますか?

答えて

0

サービス参照を右クリックし、VSをsvcinfoファイルに再生成するか、VSを使用せずにVSを使用して手動でサービスプロキシを生成することで、この問題を完全に回避できます私が知る限りベストプラクティス)。既に指摘したように、「サービス参照の追加」は、クライアントを作成するときにサービスからこれらのすべての構成値を取得するほどスマートではありません。

関連する問題