Tag: faultexception

WCF FaultException

在构建WCF服务时,如果我没有在服务中包含我的FaultException合同,我可以在客户端上创建一个WCF服务引用,其中包含Reference.cs文件中包含的所有成员。 如果我包含我的FaultException合同,会发生两件事。 在WCF测试客户端中,合同名称旁边有一个红色的“X” (CreateFaultMessage) 当我创建WCF服务引用时, 并非所有成员都包含在Reference.cs文件中。 因为我不是WCF专家,所以我希望有人能够告诉我在创建FaultException合同时我做错了什么。 下面是我在合同中的代码声明。 [OperationContract] [FaultContractAttribute(typeof(LogEventArgs), ProtectionLevel = ProtectionLevel.None)] Exception CreateFaultMessage(Exception ex, string method); 下面是实现接口的类中的方法。 注意在PostTransmissionRecord方法的catch块中调用CreateFaultMessage方法。 public bool PostTransmissionRecord(TransmissionRecord transmissionRecord) { bool blnUpdated = false; try { blnUpdated = TransmissionRecordGateway.InsertData(transmissionRecord); LogMessage.WriteEventLog(“Transmission records updated successfully”, “Ryder.ShopProcessService.SOA”, 3, null); return blnUpdated; } catch (Exception ex) { LogMessage.WriteEventLog(“Class: ShopProcessService” + CrLf + “Method: PostTransmissionRecord” […]

客户端不会捕获通用的FaultException ,只有FaultException

我已经阅读了所有有关此内容的内容,但也许我错过了一些东西(好吧,我肯定错过了一些东西,否则它会有效) 我在服务器业务层中抛出了一些exception错误: public class RfcException : Exception { public RfcException(string _m, Exception _inner) : base(_m, _inner) { } public Dictionary ExtendedProperties { get { return extendedProperties; } protected set { extendedProperties = value; } } private Dictionary extendedProperties = new Dictionary(); } 我在服务中未处理,但我有一个IErrorHandler来捕获并创建一个FaultMessage : public class FaultErrorHandler : BehaviorExtensionElement, IErrorHandler, IServiceBehavior { public bool HandleError(Exception […]