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 525951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:43:32+00:00 2026-05-13T08:43:32+00:00

When a single ClientBase<T> instance is used for multiple WCF service calls, it can

  • 0

When a single ClientBase<T> instance is used for multiple WCF service calls, it can get a channel into a faulted state (ie. when the service is down).

I would like to heal the channel automatically when the service comes up again. The only way I found is to call the following code before each method call:

if (clientBase.InnerChannel.State == CommunicationState.Faulted)
{
      clientBase.Abort();
      ((IDisposable)clientBase).Dispose();
      clientBase = new SampleServiceClientBase();
}

I got the feeling that this isn’t the right way to do it. Anyone got a better idea?

  • 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-05-13T08:43:32+00:00Added an answer on May 13, 2026 at 8:43 am

    You can’t. Once a channel is faulted, it’s faulted for good. You must create a new channel. WCF channels are stateful (in a manner of speaking), so a faulted channel means the state may be corrupted.

    What you can do is put the logic you’re using into a utility method:

    public static class Service<T> where T : class, ICommunicationObject, new()
    {
        public static void AutoRepair(ref T co)
        {
            AutoRepair(ref co, () => new T());
        }
    
        public static void AutoRepair(ref T co, Func<T> createMethod)
        {
            if ((co != null) && (co.State == CommunicationState.Faulted))
            {
                co.Abort();
                co = null;
            }
            if (co == null)
            {
                co = createMethod();
            }
        }
    }
    

    Then you can invoke your service with the following:

    Service<SampleServiceClient>.AutoRepair(ref service,
        () => new SampleServiceClient(someParameter));
    service.SomeMethod();
    

    Or if you want to use the default parameterless constructor, just:

    Service<SampleServiceClient>.AutoRepair(ref service);
    service.SomeMethod();
    

    Since it also handles the case where the service is null, you don’t need to initialize the service before calling it.

    Pretty much the best I can offer. Maybe somebody else has a better way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 265k
  • Answers 265k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer code taken from answer to this question string strUri2 =… May 13, 2026 at 12:25 pm
  • Editorial Team
    Editorial Team added an answer You can do this with HttpWebRequest and its GetResponse method,… May 13, 2026 at 12:25 pm
  • Editorial Team
    Editorial Team added an answer I don't think you can capture an arbitrary number of… May 13, 2026 at 12:25 pm

Related Questions

function showFields($selClient) { $result = mysql_query(SELECT * FROM project WHERE projectid = $selClient); $values
When a single property contains semicolons, MSBuild automatically parse the property into a list
How would I go about creating multiple documents when a single file is opening
I have a thread running that delegates out some tasks. When a single task
When a PHP application makes a database connection it of course generally needs to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.