ilansch
ilansch

Reputation: 4878

C# Async Await In WCF 4.5 and Exception handling

In WCF .net 3.5 i used the asynchronous way with IAsyncResult Begin/End operation pattern.
When i had an exception, I would return a DataContract named ErrorData.
Also, I Could use the FaultContract.

In WCF for .net 4.5, How do you handle exception ?
I saw this guide: Wcf service exception good practices

Is this relevant to .net 4.5 ? If my WCF Service catches an exception, Do I return a FaultContract ?
I could not find good references for this topic.

Upvotes: 1

Views: 2123

Answers (1)

Stephen Cleary
Stephen Cleary

Reputation: 456437

You still do need to throw a FaultContract. I have an example on my blog post "Async WCF Today and Tomorrow" - note that when that blog was written, "today" meant using the Async CTP and wrapping the async implementation in IAsyncResult methods. So the "today" approach no longer applies. The "tomorrow" section is the one that shows how to do it with async in .NET 4.5.

Upvotes: 4

Related Questions