WCF fault - The creator of this fault did not specify a reason
I was throwing a simple WCF FaultException yesterday and came across the same problem as this on the forums
The client was trying to catch a fault as below:
catch (FaultException<InvalidOperationException> fexc)
{
MessageBox.Show("A fault occurred because of an invalid operation exception"
To get it working from a server perspective I had to delcare the following:
InvalidOperationException oe = new InvalidOperationException(
"Debit amount is greater than balance in account " + accountNumber);
FaultException<InvalidOperationException> fe = new FaultException<InvalidOperationException>(oe,
new FaultReason("Debit amount is greater than balance in account " + accountNumber));
throw fe;
I also marked the service interface with the following attribute:
[
FaultContract(typeof(InvalidOperationException))]
I'm sure there must be a better way.... will followup