我有一个简单的FaultException,我把它放在WCF服务器上,并捕捉到客户端。Test = test; [DataMember]}throw new FaultException<TDetail> ex) // I expect thiscatch (FaultException ex) // But get this D:和
= new FaultException<RfcServiceFault>(serviceFault, new FaultReason(string.Format("System error occurred, exception: {0}", error)));
var faultMessage = faultException.CreateMessageFault();= new FaultException<Exception>(error, new FaultReason
当你迁移到多层的WCF时,你失去了所有这些,你需要使用FaultException机制。catch (FaultException ex) if FaultException is (PasswordExceptionFault否则,我必须有许多catch构造--每种类型的FaultException都有一个。
public double DivideByZero(int x, int y) if (y == 0) throw new FaultExceptionexp.ToString()); catch (Exception exp) Console.WriteLine(exp.ToString());在上述情况下,catch(FaultException但是,当我将ArgumentException删除为具有catch(F
好吧,我把自己搞糊涂了。我有一个调用另一个WCF服务(服务B)的WCF服务(服务A)。当我在服务B上抛出异常时,例如throw new Exception("test"),那么服务A不会得到异常,而是在响应消息上将IsFault设置为真。if (responseMessage.IsFault) {}谢谢