You must Sign In to post a response.
  • Category: WCF

    Throwing an exception from callback in WCF Async

    I am using WCF Async calls in my project and i am using Client side asynchronous methods. I have a scenario like below -

    //Code in Business Layer and this method is called from Web layer
    private void GetGeneralNews()
    client.BeginGetGeneralNewsFeed(GeneralNewsCallback, null);

    private static void GeneralNewsCallback(IAsyncResult asyncResult)
    string response = string.Empty;

    response = client.EndGetGeneralNewsFeed(asyncResult);
    catch(Exception ex)
    throw ex; // Here is the problem. It does not throw the exception to the web layer instead it will suppress the error.

    So as shown in the above code snippet it does not throw the exception from business layer to web layer as it will be suppressed here in business layer itself.

    Please give some ideas to proceed.

  • #757665
    Hi Abhijith,

    Find the attached example.
    Hope it will be helpful for you.

    Nirav Lalan
    DNS Gold Member
    "If you can dream it, you can do it."


    Delete Attachment

  • #757672

    Check these links for Fault Exceptions in WCF

  • #757704
    Hi Guys,

    I will be using IAsyncResult for this and by the way i there is no problem of getting the errors in client side. The problem is while throwing an exception to the caller layer and if i check it in CallStack i did not find the caller methods.

    So Question is -

    1) How can i throw the exception to the caller method in different layer in IAsyncResult. ?

    Thanks & Regards,

    Mail -
    Check My Blog -

  • Sign In to post your comments