6

Should I just ignore a first chance exception in WCF?

 2 years ago
source link: https://www.codesd.com/item/should-i-just-ignore-a-first-chance-exception-in-wcf.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Should I just ignore a first chance exception in WCF?

advertisements

Running a WCF service inside Visual Studio, I see a load of exceptions in the Debug output.

A first chance exception of type 'System.ServiceModel.FaultException' occurred in System.ServiceModel.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.Channels.dll

They seem to get thrown irregularly: in any case I haven't been able to work out any pattern (i.e. anywhere from every few seconds, to several tens of seconds).

If I set debug to break on FaultException, I see that they are being thrown by System.ServiceModel.Dispatcher.ErrorBehavior.ThrowAndCatch(Exception e, Message message).

The exception message is {"The message with To '' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree."}.

The obvious answer would seem to be "well your address is empty". But this happens before any clients have connected.

Is this just 'normal', or a symptom of something I'm doing wrong?


The quick answer is "yes, you could ignore first chance exceptions". They are exceptions which have actually already been handled. Therefore, they should be considered as a normal execution workflow.

The visual studio notifies the developer for each exception it occurs, even if it is handled. Each exception throws a "first chance exception" which does not interrupt a normal debugging session. If this first chance exception is not handled, then the debugging session gets interrupted by a "second chance exception". The value of the "first chance exceptions" is only for developer's insight knowledge.

In this blog post you can see more details about first chance exceptions. Copying from the referenced post:

Does a first chance exception mean there is a problem in my code? First chance exception messages most often do not mean there is a problem in the code. For applications / components which handle exceptions gracefully, first chance exception messages let the developer know that an exceptional situation was encountered and was handled.

Hope I helped!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK