WCF Unhandled FaultException was not handled by usercode

Offler picture Offler · Oct 24, 2012 · Viewed 10k times · Source

i'm trying to use a WCF Plain service with Telerik OpenAccess in VS 2012 with .net 4.5.

I tried the telerik developers manual and created the service and a client.

In the service interface IEntitiesModel I put

[OperationContract]
[FaultContract(typeof(string))]
PersistentDto ReadPersistentDto(string dtoKey);

In the EntitiesModel.SVC for the method I used an easy construct as first try:

public PersistentDto ReadPersistentDto(string dtoKey)
{
   throw new FaultException("test");
} 

In user code of Consumer i put a catch for the exception.

Now the problem is:

Every time the service is called, Visual Studio stops in "throw new FaultException" with the error message, that FaultException was not handled by usercode. If i continue with F5, the exception is also caught by usercode of consumer.

Why does it stop in the service?

In my understanding a FaultException is something which should be passed to the consumer of a service.

What should i do to throw a FaultException correctly?

Answer

Rohit Vats picture Rohit Vats · Oct 24, 2012

Go to Debug -> Exceptions and uncheck the checkbox under Thrown column for row CLR exception.

If that checkbox is checked, it will cause the debugger to stop at every location where you are throwing exception.