我已经成功地在我的 web service 中抛出了一些 SOAP 异常。我想捕获这些异常并访问调用异常时调用的字符串和 ClientFaultCode。以下是我在 web service 中的一个异常示例:
throw new SoapException("You lose the game.", SoapException.ClientFaultCode);
我在客户端尝试调用来自 Web 服务的方法,该方法可能会抛出异常,并将其捕获。问题是我的 catch 块没有做任何事情。请看这个示例:
try
{
service.StartGame();
}
catch
{
// missing code goes here
}
我怎样才能访问抛出异常时调用的字符串和 ClientFaultCode?