How to heal faulted WCF channels?

后端 未结 2 1708
别那么骄傲
别那么骄傲 2020-12-09 19:09

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

2条回答
  •  一向
    一向 (楼主)
    2020-12-09 19:46

    This is what I'm currently doing, but I can't say this is the best option either.

    I recreate the proxy when an exception is caught on the call.

    try
    {
        ListCurrentProcesses();
    }
    catch (TypeLoadException ex)
    {
        Debug.Print("Oops: " + ex.Message);
        m_Proxy = new ProcessManagerProxy();
    }
    catch (EndpointNotFoundException endpointEX)
    {
        Debug.Print("Oops: " + endpointEX.Message);
        m_Proxy = new ProcessManagerProxy();
    }
    catch (CommunicationException communicationEx)
    {
        Debug.Print("Oops: " + communicationEx.Message);
        m_Proxy = new ProcessManagerProxy();
    }
    

提交回复
热议问题