static Exception GetFaultException( Fault fault, string responseText) { Exception x = null; if (fault == null) { return(new FaultException( new FaultReason( new[] { new FaultReasonText("Unresolved ProtocolException."), new FaultReasonText(responseText), }))); } var exceptionFactory = Fault.GetFaultToExceptionFactory(fault.GetType()); if (exceptionFactory != null) { x = exceptionFactory(fault); } else { x = (FaultException)typeof(FaultException <>) .MakeGenericType(fault.GetType()) .GetConstructor(new Type[] { fault.GetType() }) .Invoke(new object[] { fault }) ; } x.Data["ResponseText"] = responseText; return(x); }