What is the best approach to handle exceptions in WCF service?

后端 未结 4 789
悲&欢浪女
悲&欢浪女 2020-12-04 22:11

I have a WCF service deployed on two or more remote machines and there is a desktop based application that is used by the client to access any wcf service.

T

4条回答
  •  一向
    一向 (楼主)
    2020-12-04 23:11

    try
    {
      // Actions
    }
    catch (Exception ex)
    {
      // Log the exception
      // Throw Fault Exception back to client
      FaultException fe = new FaultException(ex.Message, new FaultCode("Your fault code"));
      //throw fault exception back to WCF client
      throw fe;
    }           
    

提交回复
热议问题