-1

別の参照が既に作成されているプロジェクトにサービス参照を追加しようとしています。これらのプロジェクトで使用されている App.Config と Web.config をコピーし、追加するサービスに適合させました。また、契約書をコピーして翻案しましたが、うまくやったと思います。

私の質問は次のとおりです。サービス参照を追加しているときに間違った、またはよくある間違いをした可能性があると思いますか、または mex エンドポイントを使用してプロジェクトにサービス参照を追加する際のエラーに関する問題をどこでどのようにトラブルシューティングできますか?

エラー ここに画像の説明を入力

エラー詳細

ここに画像の説明を入力

追加情報:

1つの操作(「開始」)のみとしての契約。

接続は net.tcp を介して行われています。

サービスとオブジェクトは異なるプロジェクトです。

オブジェクトには App.Config があり、サービスには Web.Config があります

アップデート

サービス Web.Config

 <?xml version="1.0"?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\inetpub\SocketListener\logs\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>


  <system.web>
    <compilation debug="true" targetFramework="4.5.1" />
  </system.web>


  <system.serviceModel>
    <services>
      <service name="SocketListener.SocketListener">
        <endpoint address="" binding="netTcpBinding" contract="SocketListener.ISocketListener">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://<IP>/SocketListener/SocketListener.svc" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name="netTcpBindingConf" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" hostNameComparisonMode="StrongWildcard" transactionFlow="false" transferMode="Buffered" maxBufferPoolSize="20000000"
            maxBufferSize="20000000"
            maxConnections="20000000"
            maxReceivedMessageSize="20000000"
            portSharingEnabled="true"
            listenBacklog="20000000">

        </binding>
      </netTcpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200" maxConcurrentInstances="200" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
  </startup>
</configuration>
4

2 に答える 2

0

このエラーは、ファイル *.svc の構成ミスと IIS の構成ミスが原因で発生しました。

ファイルミス構成

違う

<%@ ServiceHost Language="C#" Debug="true" Service="Service" %>

正しい

<%@ ServiceHost Language="C#" Debug="true" Service="<Namespace>.<Class used in the Service>" %>

IIS の構成ミス

違う

IIS に展開されたアプリケーションの詳細設定で、有効なプロトコルにhttpがありました

正しい

IIS に展開されたアプリケーションで、[詳細設定]で、有効なプロトコルをnet.tcpに変更しました

于 2015-06-25T13:56:29.613 に答える
0

サービスにbehaviorConfigurationを追加してみてください:

<?xml version="1.0"?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\inetpub\SocketListener\logs\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>


  <system.web>
    <compilation debug="true" targetFramework="4.5.1" />
  </system.web>


  <system.serviceModel>
    <services>
      <service name="SocketListener.SocketListener" behaviorConfiguration="ServiceBeh">
        <endpoint address="" binding="netTcpBinding" contract="SocketListener.ISocketListener">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://<IP>/SocketListener/SocketListener.svc" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name="netTcpBindingConf" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" hostNameComparisonMode="StrongWildcard" transactionFlow="false" transferMode="Buffered" maxBufferPoolSize="20000000"
            maxBufferSize="20000000"
            maxConnections="20000000"
            maxReceivedMessageSize="20000000"
            portSharingEnabled="true"
            listenBacklog="20000000">

        </binding>
      </netTcpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBeh">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200" maxConcurrentInstances="200" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
  </startup>
</configuration>
于 2015-06-24T16:03:37.180 に答える