PC Review


Reply
Thread Tools Rate Thread

Console application failing to catch errors

 
 
Mantorok
Guest
Posts: n/a
 
      25th Apr 2007
Hi all

I have a console application that runs every night via a scheduled task,
there is a try-catch block in my Main class, whenever an error is caught it
is written to a log file and then emailed to several people. The
application is run using a domain service account, if the program is
successful it emails this result fine.

The problem is, the catch doesn't seem to perform correctly if the program
fails, all I end up with is an entry in the event-log with almost
meaningless error details.

My only thought was that maybe these errors are occurring in my
multi-threaded calls (there are a few).

Is there any reason why the catch would fail? I'm running out of ideas.

Thanks
Kev


 
Reply With Quote
 
 
 
 
Lee Alexander
Guest
Posts: n/a
 
      25th Apr 2007
Hi Kev,

Perhaps you don't have permission on the log file and the application is
bombing out before the sending mail portion of the program is sent.
--
Regards
Lee Alexander
www.feedghost.com
An RSS Reader for Vista & XP
Synchronize, search, tag and share.

"Mantorok" <(E-Mail Removed)> wrote in message
news:f0n7sr$fd$(E-Mail Removed)...
> Hi all
>
> I have a console application that runs every night via a scheduled task,
> there is a try-catch block in my Main class, whenever an error is caught
> it is written to a log file and then emailed to several people. The
> application is run using a domain service account, if the program is
> successful it emails this result fine.
>
> The problem is, the catch doesn't seem to perform correctly if the program
> fails, all I end up with is an entry in the event-log with almost
> meaningless error details.
>
> My only thought was that maybe these errors are occurring in my
> multi-threaded calls (there are a few).
>
> Is there any reason why the catch would fail? I'm running out of ideas.
>
> Thanks
> Kev
>



 
Reply With Quote
 
Chris Nahr
Guest
Posts: n/a
 
      25th Apr 2007
On Wed, 25 Apr 2007 10:43:49 +0100, "Mantorok" <(E-Mail Removed)> wrote:

>My only thought was that maybe these errors are occurring in my
>multi-threaded calls (there are a few).


Quite possibly. If you're doing stuff in worker threads you need to
have an exception handler on each worker thread that either logs the
error or communicates the error back to the main thread. If a worker
thread fails due to an exception it won't communicate anything to the
main thread by default, it will simply shut down.
--
http://www.kynosarges.de
 
Reply With Quote
 
Mantorok
Guest
Posts: n/a
 
      25th Apr 2007

"Chris Nahr" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Wed, 25 Apr 2007 10:43:49 +0100, "Mantorok" <(E-Mail Removed)> wrote:
>
>>My only thought was that maybe these errors are occurring in my
>>multi-threaded calls (there are a few).

>
> Quite possibly. If you're doing stuff in worker threads you need to
> have an exception handler on each worker thread that either logs the
> error or communicates the error back to the main thread. If a worker
> thread fails due to an exception it won't communicate anything to the
> main thread by default, it will simply shut down.


I'm pretty sure that's the problem, how do you catch exceptions from
additional threads?

Thanks
Kev


 
Reply With Quote
 
Mantorok
Guest
Posts: n/a
 
      25th Apr 2007
Permissions is ok as the log file is being written to before-hand.

Kev

"Lee Alexander" <lee@feedghost_dot_com> wrote in message
news:(E-Mail Removed)...
> Hi Kev,
>
> Perhaps you don't have permission on the log file and the application is
> bombing out before the sending mail portion of the program is sent.
> --
> Regards
> Lee Alexander
> www.feedghost.com
> An RSS Reader for Vista & XP
> Synchronize, search, tag and share.
>
> "Mantorok" <(E-Mail Removed)> wrote in message
> news:f0n7sr$fd$(E-Mail Removed)...
>> Hi all
>>
>> I have a console application that runs every night via a scheduled task,
>> there is a try-catch block in my Main class, whenever an error is caught
>> it is written to a log file and then emailed to several people. The
>> application is run using a domain service account, if the program is
>> successful it emails this result fine.
>>
>> The problem is, the catch doesn't seem to perform correctly if the
>> program fails, all I end up with is an entry in the event-log with almost
>> meaningless error details.
>>
>> My only thought was that maybe these errors are occurring in my
>> multi-threaded calls (there are a few).
>>
>> Is there any reason why the catch would fail? I'm running out of ideas.
>>
>> Thanks
>> Kev
>>

>
>



 
Reply With Quote
 
Mantorok
Guest
Posts: n/a
 
      25th Apr 2007

"Chris Nahr" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Wed, 25 Apr 2007 10:43:49 +0100, "Mantorok" <(E-Mail Removed)> wrote:
>
>>My only thought was that maybe these errors are occurring in my
>>multi-threaded calls (there are a few).

>
> Quite possibly. If you're doing stuff in worker threads you need to
> have an exception handler on each worker thread that either logs the
> error or communicates the error back to the main thread. If a worker
> thread fails due to an exception it won't communicate anything to the
> main thread by default, it will simply shut down.


It is that, I'm now handling my exceptions inside the appropriate threads
and it's working now.

Thanks
Kev


 
Reply With Quote
 
Chris Nahr
Guest
Posts: n/a
 
      25th Apr 2007
On Wed, 25 Apr 2007 14:54:33 +0100, "Mantorok" <(E-Mail Removed)> wrote:

>I'm pretty sure that's the problem, how do you catch exceptions from
>additional threads?


In the same way as usual, just make sure the exception handler runs on
the thread in question...
--
http://www.kynosarges.de
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Spell Checker Is Failing To Catch Misspelled Words...How To Fix or Reset?? Susan Windows Vista Mail 2 22nd Jan 2010 10:48 PM
Catch block is failing to catch exceptions when not run from MSDev CodeSlayer Microsoft C# .NET 2 16th Feb 2006 06:42 PM
Microsoft AntiSpyware Beta1: Failing to catch spyware Steve Spyware Application Compatibility 3 22nd Apr 2005 11:06 AM
How to catch a failing thread. Frank Rizzo Microsoft C# .NET 1 21st Feb 2005 06:29 PM
catch CTRL-C into a console application Claudiu Felecan Microsoft C# .NET 1 29th Jan 2004 05:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:54 AM.