私はWCFでいくつかのテストを行いましたが、1つのことを理解することはできません。なぜ、WCF非同期メソッドは同期がFaultExceptionをスローしないのですか?
次のサービスてきた私は、次の実装で
[ServiceContract]
public interface ICommunicationIssuesService:IService
{
[OperationContract]
void TestExceptionInActionSync();
[OperationContract]
Task TestExceptionInActionAsync();
}
を:クライアント側で
public class CommunicationIssuesService : ICommunicationIssuesService
{
public void TestExceptionInActionSync()
{
throw new InvalidOperationException();
}
public async Task TestExceptionInActionAsync()
{
throw new InvalidOperationException();
}
}
、私はそれで、のChannelFactoryを作成します。
//Test Synchronous
//... Setup of the channelFactory
ICommunicationIssuesService channel =_channelFactory.CreateChannel()
try{
channel.TestExceptionInActionSync();
}catch(FaultException<ExceptionDetail>){
//I receive an FaultException
}
//Test Asynchronous
//... Setup of the channelFactory
ICommunicationIssuesService channel =_channelFactory.CreateChannel()
try{
channel.TestExceptionInActionAsync();
}catch(AggregateException){
//I receive an AggregateException, I guess because it's a Task behind
}
私が理解できないことは、ここでFaultException(またはAggregateException)を受け取らない理由です。