net.pipeバインディングを使用して、サービスとクライアントの相互作用のインプロセス単体テストを作成しようとしています。優れたWCFサービスと同様に、サービス操作でFaultContractAttributeを使用して、発生する可能性のある障害(ラップされた例外)をメタデータに公開します。XML (App.config)を使用してクライアントエンドポイントとサービスエンドポイントを構成したいと思います。 ただし、障害がスローされるたびに、それは単にCommunicationExceptionの「パイプが閉じられました」であり、私が期待していた型指定された障害ではありません。
System.ServiceModel.CommunicationException: There was an error reading from the pipe: The pipe has been ended. (109, 0x6d).
net.pipeにIMetadataExchangeエンドポイントを追加しようとしましたが、機能しませんでした。私も試しました。Vista上にあるため、httpエンドポイントのACLをnetshする必要がありました。それもうまくいきませんでした。
カスタム例外クラス:
public class ValidationException : ApplicationException { }
これは構成での最新の試みですが、「サービスによって実装されたコントラクトのリストにコントラクト名'IMetadataExchange'が見つかりませんでした」というメッセージが表示されます。
これを行う方法の例または推奨事項へのリンクをいただければ幸いです。
<system.serviceModel>
<client>
<endpoint name="Client"
contract="IService"
address="net.pipe://localhost/ServiceTest/"
binding="netNamedPipeBinding"
bindingConfiguration="netPipeBindingConfig" />
</client>
<services>
<service
name="Service"
behaviorConfiguration="ServiceFaults">
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/ServiceTest/"/>
<add baseAddress="http://localhost/ServiceTest/"/>
</baseAddresses>
</host>
<endpoint
address=""
binding="netNamedPipeBinding"
bindingConfiguration="netPipeBindingConfig"
name="ServicePipe"
contract="IService" />
<endpoint
address="MEX"
binding="mexNamedPipeBinding"
bindingConfiguration="mexNetPipeBindingConfig"
name="MexUserServicePipe"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<netNamedPipeBinding>
<binding name="netPipeBindingConfig"
closeTimeout="00:30:00"
sendTimeout="00:30:00" />
</netNamedPipeBinding>
<mexNamedPipeBinding>
<binding name="mexNetPipeBindingConfig"></binding>
</mexNamedPipeBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceFaults">
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
<behavior name="MEX">
<serviceMetadata
httpGetEnabled="true"
httpGetUrl="http://localhost/ServiceTest/MEX"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>