0

私の wcf サービス ライブラリには、次の App.config があります。

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="addr" value="net.tcp://localhost:22222/AdministrationService/"/>
  </appSettings>
  <system.serviceModel>
    <services>
      <service name="Watchman.WcfService.AdministrationService" behaviorConfiguration="MyBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:22222/AdministrationService/"/>
          </baseAddresses>
        </host>
        <endpoint name="Ep1" address="net.tcp://localhost/AdministrationService/" binding="netTcpBinding" bindingConfiguration="DuplexBinding" contract="Watchman.WcfService.Interfaces.IAdministration"/>
        <endpoint name="mex" address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="MyBehavior">
          <serviceThrottling maxConcurrentSessions="10000"/>
          <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost/AdministrationService/Ep1/wsdl"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <bindings>
      <netTcpBinding>
        <binding name="DuplexBinding" sendTimeout="00:00:01">
          <reliableSession enabled="true"/>
          <security mode="None"/>
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
  </startup>

</configuration>

しかし、私はエラーが発生しました:

"The Address property on ChannelFactory.Endpoint was null.  The ChannelFactory's Endpoint must have a valid Address specified."

アプリケーションがこの tcp.net エンドポイントをサポートしていないようです。なんで?

4

3 に答える 3

1

この App.config が wcf サービス ライブラリにあります

wcf クラス ライブラリに app.config があり、WCF がそこから設定を読み取ることを期待することはできません。意味がありません。app.config などの構成ファイルは、最終的な実行可能アプリケーション プロジェクト (コンソール アプリケーション、WinForms、WPF など) で定義されます。または、Web アプリケーションの場合は、web.config を使用します。しかし、クラス ライブラリの app.config などはありません。そのため、クラス ライブラリを使用してアプリケーションの app/web.config にこの WCF 構成を含める必要がある場合があります。

于 2011-09-08T19:49:39.340 に答える
0

net.tcp のベース アドレスを指定したので、net.tcp エンドポイントのアドレスは相対アドレスになります。したがって、事実上、エンドポイントのアドレスは net.tcp://localhost:22222/AdministrationService/localhost/AdministrationService/ になります。

エンドポイントのアドレスを相対アドレスに変更し、svcutil を使用してプロキシ クラスを再生成します。

于 2011-09-09T13:01:29.770 に答える
0

svcutil が wcf クライアント プロジェクトで不正なエンドポイントを生成することに気付きました。あります

<endpoint binding="basicHttpBinding"
          bindingConfiguration="DefaultBinding_IAdministration" 
          contract="IAdministration" 
          name="DefaultBinding_IAdministration_IAdministration" />"

net.tcp私のエンドポイントの代わりに。

ProxyFile.csまた、それはの生成とApp.configからの生成によるものであることも観察しました

svcutil WcfServiceLibrary.dll

次のようなメタデータからこのファイルを生成すると:

svcutil net.tcp://localhost:8080/AdministrationService/mex /language:C# /out:ProxyFile.cs /config:App.config

その後、正常に動作します(アプリ構成では、正しいnet.tcpエンドポイントが説明されています)

svcutil と *.dll の連携がうまくいかない理由を知っている人はいますか?

于 2011-09-11T10:56:26.590 に答える