1

VS2010 で WCF アプリケーションを開発しています。IDE 内デバッガーを使用してホスト アプリケーションとクライアントを実行すると、すべてが意図したとおりに機能します。

ただし、2 つの実行可能ファイルを手動で (/bin/Debug/ フォルダーに移動して) 実行すると、クライアントから次の例外が発生します。

System.Net.Sockets.SocketException: ターゲット マシンがアクティブに拒否したため、接続できませんでした 127.0.0.1:8732

奇妙なことに、app.config ファイルで、8732 ではなくポート 5000 を使用するように指定しています。

どうしたの?前もって感謝します。

編集: ホスト アプリケーションの app.config は次のとおりです。

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

2 に答える 2

4

ユーザーが 13 のコメントを通過する必要がないように投稿

この場合の問題は、ユーザーがマルチプロジェクト ソリューションを実行していたことです。その場合、実行されているプロジェクトは、構成ファイルが重要なプロジェクトです。

WcfService を実行している場合web.configは、適切なポートを使用するようにファイルを構成するために、サービスを含むプロジェクトが必要です。

WcfService をテストする場合は、テスト プロジェクトのapp.configファイルが適切なポートを使用するように構成されている必要があります。

これは、Web サービスの初心者が犯す一般的なエラーであり、恥ずべきことではありません。

于 2012-03-14T22:23:30.047 に答える
0

WireSharkのようなものを使ってみましたか? 両方のエンドポイントで実行することは、ソケットの問題をトラブルシューティングする良い方法です。

于 2012-03-14T21:15:12.187 に答える