Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7720141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:35:22+00:00 2026-06-01T03:35:22+00:00

I have a series of WCF services that invoke methods on the client again

  • 0

I have a series of WCF services that invoke methods on the client again (using WcfDuplexChannels) based on events at the server side. However, it seems there are quite some exceptions that can occur, so right now I have a huge try/catch block around every line calling back to the client, ending with disabling of the event in case any exception occurs. Besides being cumbersome to write every time, I’m not sure if I could simplify the try catch block by catching just a few base exceptions? Right now I don’t really care what’s causing the exceptions (I don’t care whether it’s faulted, aborted, disposed or timed out) but I do log the different exceptions.

I also read about IErrorHandler, but will that actually be suitable when invoking a method on the client?

Here’s a sample of my current strategy:

    private void OnProductChanged(List<DTO> products)
    {
        try
        {
            client.OnProductChanged(products);
            return;
        }
        catch (TimeoutException)
        {
            log.Info("Communication to client timed out.");
        }
        catch (CommunicationObjectAbortedException)
        {
            log.Info("Connection to client is in aborted state.");
        }
        catch (CommunicationObjectFaultedException)
        {
            log.Info("Connection to client is in faulted state.");
        }
        catch (CommunicationException ce)
        {
            log.InfoFormat("CommunicationException occured on product change notification: {0}.", ce.Message);
        }
        catch (ObjectDisposedException)
        {
            log.Info("Communication channel is disposed.");
        }
        catch (Exception e)
        {
            log.WarnFormat("Unhandled {0} on client callback: {1}", e.GetType(), e.Message);
        }

        SendProductChanged = false;
    }

The SendProductChanged = false; line will take care of unbinding the event handler.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:35:23+00:00Added an answer on June 1, 2026 at 3:35 am

    You can write a wrapper method which takes Actions of Funcs as parameters and you can use try catch blocks inside this function. You can call your functions using this function; something like:

    public void CallMethod(Action methodToBeCalled)
    {
       try
       {
          methodToBeCalled();
       }
       catch 
       .....
       ....
    }
    

    Then call your functions like:

    CallMethod(() => client.OnProductChanged(products));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a series of .NET WCF RESTFul services that can produce either JSON
I'm building a series of WCF Services that are going to be used by
I have a series of functional tests against a web application that correctly run,
We have a series of drop down controls that determine the sort order of
I have a series of text that contains mixed numbers (ie: a whole part
I have a series of Extension methods to help with null-checking on IDataRecord objects,
I have a WCF service that I want to use the async pattern on
I have successfully implemented a standard WCF service bound to MSMQ using the net.msmq
I have web site which serves web services (a mixture of .asmx and WCF)
I have a site that host more then 60 services. With the simplified version

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.