1

1つのソリューションに2つのプロジェクトがあります。1つのプロジェクト(MainProjectと呼びましょう)が実行可能ファイルになります。もう1つのプロジェクトは、ControlsProjectと呼びます。これには、が含まUserControlれ、MainProject内で参照(および使用)されます。ControlsProjectには、WCFサービスリファレンスもあります。

この構成に関して2つの質問があります。

  1. WCF構成をControlsProjectからMainProjectにコピーすることはできますか(「別のプロジェクトにWeb参照エンドポイント構成を含める方法」ごとにコピーできるとは思いません)
  2. ControlsProject構成では、コントラクトには完全修飾名前空間ではなく、' ServiceName.IServiceInterfaceName'などの名前があります。ControlsProjectの出力はMainProjectのbinフォルダーにあるファイルになるため、コントラクト名はどのようになりますか?

構成をコピーしようとしましたが、例外が発生しました: " Could not find default endpoint element that references contract 'MyService.IMyService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."構成をコピーしたときに、インターフェイスの名前を。として完全に修飾しましたControlsProject.MyService.IMyService

あなたが提供できるどんな助けも大歓迎です!

更新 (2011年7月14日午後5時28分EST)

これが私のクライアントapp.configからのスニペットです:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IStatService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://intranet/StatService.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IStatService"
            contract="StatService.IStatService" name="BasicHttpBinding_IStatService" />
    </client>
</system.serviceModel>

これが私のWebサービスweb.configからのスニペットです:

<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior name="">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
4

1 に答える 1

0

"Could not find default endpoint element for such and such contract" が表示される場合は常に、実際のコントラクト (インターフェイス) が app.config ファイルで正しく参照されていません。コントロール プロジェクトのインターフェイス コントラクトに移動し、名前空間を再確認します。正確な名前空間が必要です。app.config のコントラクト要素として「インターフェイス名」を指定します。また、サービス名=Namespace.MyService が正しい名前空間とクラスであることを確認する必要があります。あなたが正しいかどうかを知る簡単な方法の 1 つ (これは resharper を使用している場合のみ)、サービス名 = を宣言する appconfig で、カーソルをサービス名と名前空間の上に置き、F12 を押します。存在しない名前空間とクラスを参照しています。そのコントラクトで F12 キーを押しても、contract= についても同じことが言えます。

于 2011-07-14T15:40:37.113 に答える