7

NetTcpBinding で苦労しています。

WCF サービスを実行すると、次のようになります。

System.InvalidOperationException: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
   at System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses)
   at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress)
   at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection)
   at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, String configurationName)
   at System.ServiceModel.ServiceHostBase.ApplyConfiguration()
   at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)
   at System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses)
   at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(Type type, ServiceKind kind)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)

WCFSvcHost を使用してデフォルトでアプリケーションを実行すると、これが発生します。追加のコードはありません。新しい wcf サービスのデフォルト コードのみです。私がやりたかったのは、バインディングを tcp に変更することだけでした。

この問題を解決するにはどうすればよいですか?

編集:これが私のWCFのApp.configです

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="tcpBinding" transferMode="Streamed" portSharingEnabled="false">
          <reliableSession enabled="true" />
          <security mode="None">
            <transport clientCredentialType="None" protectionLevel="None" />
            <message clientCredentialType="None" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="WcfServiceLibrary1.Service1Behavior"
        name="WcfServiceLibrary1.Service1">
        <endpoint address="" binding="wsHttpBinding" contract="WcfServiceLibrary1.IService1">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <endpoint address="Service" binding="netTcpBinding" bindingConfiguration="tcpBinding"
          name="testTcp" contract="WcfServiceLibrary1.IService1" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfServiceLibrary1.Service1Behavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>
4

5 に答える 5

18

これで問題は修正されたと思いますが、すべての掲示板が導くbaseAddressesとは実際には何の関係もありません。答えはhttp://social.msdn.microsoft.com/forums/en-US/wcf/thread/c9f8d99d-89ee-4573-8528-a21b047bad11で見つかりました。IIS 7.xを使用している場合:IISで仮想ディレクトリ/アプリケーションを右クリックし、[アプリケーションの管理]->[詳細設定]を選択します。[有効なプロトコル]セクションで、net.tcpを追加します(例:http、net.tcp)。これは、このプロトコルをすでにサイトレベルで追加した場合でも必要です。

于 2010-04-21T18:48:29.210 に答える
7

このセクションで

<host>          
  <baseAddresses>            
    <add baseAddress="http://localhost:8731/.../" />   
  </baseAddresses>        
</host>

net.tcp:// ベース アドレスを追加します。

<host>
  <baseAddresses>
    <add baseAddress="http://localhost:8732/" />
    <add baseAddress="net.tcp://localhost"/>
  </baseAddresses>
</host>
于 2009-08-19T04:20:36.670 に答える
3

ポートを共有できます。それほど難しくありません。

IIS で有効なプロトコルを選択するときは (サイトを右クリック -> Web サイトの管理 -> 詳細設定)、スペースを使用しないでください。"http,net.tcp" の代わりに "http, net.tcp" がある場合は機能せず、代わりにこの正確なエラーが発生します。

詳細はこちら: http://www.weeksofprogramming.com/post/Could-not-find-a-base-address-Check-for-spaces-in-IIS7.aspx

于 2010-12-12T18:28:18.493 に答える
2

IISサイトでnet.tcpバインディングを構成し、有効なプロトコルを「詳細設定を使用してhttp、net.tcp」として設定します。これは機能するはずです。

于 2010-11-17T11:12:27.730 に答える
1
  1. Net.Tcp ポート共有サービスがマシンで開始されていることを確認します
  2. 構成の netTcpBinding portSharingEnabled 属性が true であることを確認します。(WCF4 では、このバインディング仕様を net.tcp のデフォルトにしたい場合、バインディング要素に名前を指定する必要はありません)
于 2010-07-30T17:50:04.770 に答える