0

WCF で Silverlight 3 Prism (CAB) を使用しています

Prism モジュールで WCF サービスを呼び出すと、同じエラーが発生します。

「サービス モデル クライアント構成セクションでコントラクト 'IMyService' を参照する既定のエンドポイント要素が見つかりませんでした。これは、アプリケーションの構成ファイルが見つからなかったか、このコントラクトに一致するエンド ポイント要素がクライアント要素で見つからなかったためである可能性があります」

モジュールの ServiceReferences.ClientConfig ファイルではなく、シェルの .xap ファイルで ServiceReferences.ClientConfig ファイルを検索していることがわかります。Silverlight シェル アプリケーションの既存の ServiceReferences.ClientConfig ファイルにエンドポイントとバインディングを追加しました (独自の WCF サービスを呼び出します)。

次に、Shell アプリを再構築して、Web プロジェクトの ClientBin フォルダー用の新しい .xap ファイルを生成する必要がありました。

次に、コードでサービスを設定するように変更しました。

// create the binding elements
BinaryMessageEncodingBindingElement binaryMessageEncoding = new BinaryMessageEncodingBindingElement();
HttpTransportBindingElement httpTransport = new HttpTransportBindingElement() 
{ MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue};

HttpsTransportBindingElement httpsTransport = new HttpsTransportBindingElement() 
{ MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue };

// add the binding elements into a Custom Binding
CustomBinding customBinding;
if (Application.Current.Host.Source.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase))
{
    customBinding = new CustomBinding(binaryMessageEncoding, httpsTransport);
}
else
{
    customBinding = new CustomBinding(binaryMessageEncoding, httpTransport);
}

// create the Endpoint URL
EndpointAddress endpointAddress = new EndpointAddress(

"http://localhost/Test/TestModule/Test.TestModule.WCF/TestModuleService.svc");

// create an interface for the WCF service
var service = new TestModuleServiceClient(customBinding, endpointAddress);
4

1 に答える 1

1

この投稿は同様の状況を扱っています:

ありがとう、ダミアン・シェンケルマン

http://blogs.southworks.net/dschenkelman

于 2009-10-27T17:40:04.173 に答える