3

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?

1
  • Have you enabled First Chance Exceptions during debugging? If yes, then every thrown exception will cause the debugger to stop at the location where exception was thrown.
    – Ganesh R.
    Commented Oct 24, 2012 at 7:03

4 Answers 4

9

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.

1
  • 1
    thank you for this answer :) got my Ierrorhandler in order and everything now. didnt know it worked
    – Dendei
    Commented Mar 1, 2013 at 10:35
1

This is related to setting. You can do required setting by going to Tools-> options Now switch to debugging menu and uncheck
"Enable the exception assistant" and
"Enable just my code" enter image description here

0

The server does not know that the client will handle the exception (how should he?). This is why the debugger tells you that it is unhandled.

You have also throw the fault like this:

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

This matches your declaration:

[FaultContract(typeof(string))]
0

It's related with debbugging. However it won't stop your service while executing (unless you don't manage the exception properly).

As RV1987 said, if VS has CLR Exceptions enabled, it will let you know anytime an exception has been thrown.

Not the answer you're looking for? Browse other questions tagged or ask your own question.