Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
In my web application I have a one way async WCF service. In this service I want to catch all exceptions like I do in global.asax Application_Error. I've tried to handle these events:

C#
AppDomain.CurrentDomain.UnhandledException += (s,e) => { //some logic };
AppDomain.CurrentDomain.FirstChanceException += (s,e) => { //some logic };

even tried:

//this one is for Win Forms Application
C#
Application.ThreadException += (s,e) => { //some logic };

and

//this one is for Web Application
C#
HttpContext.Current.ApplicationInstance.Error += (s,e) => { //some logic };

But none of these handlers are reached.

Any ideas, what else can I try?
Posted
Comments
pramod.hegde 26-Oct-12 11:35am    
Please improve your question.
Where you are trying to catch the exception?
In the client side (where you are referencing WCF service)
OR
In the WCF service itself?
GGev 26-Oct-12 11:43am    
I want to catch all exceptions that were thrown in WCF in the service itself
Sergey Alexandrovich Kryukov 26-Oct-12 12:56pm    
Could it be possible that they are caught in the async. operation which creates its own thread behind the scene? I would rather question why using async API (do you, or you organize async. operation by yourself, using threads explicitly?). I would suggest using explicit threads, the get more control, and make your logic more linear, straightforward and universal...
--SA
Sergey Alexandrovich Kryukov 26-Oct-12 12:54pm    
How do you know that you really had unhandled exception? Maybe you caught it somewhere else on the same stack, maybe even silently?
--SA

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900