473,666 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Console application failing to catch errors

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
Apr 25 '07 #1
6 2033
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" <no**@none.comw rote in message
news:f0******** *@newsfeed.th.i fl.net...
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

Apr 25 '07 #2
On Wed, 25 Apr 2007 10:43:49 +0100, "Mantorok" <no**@none.comw rote:
>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
Apr 25 '07 #3

"Chris Nahr" <di******@kynos arges.dewrote in message
news:td******** *************** *********@4ax.c om...
On Wed, 25 Apr 2007 10:43:49 +0100, "Mantorok" <no**@none.comw rote:
>>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
Apr 25 '07 #4
Permissions is ok as the log file is being written to before-hand.

Kev

"Lee Alexander" <lee@feedghost_ dot_comwrote in message
news:uo******** ******@TK2MSFTN GP05.phx.gbl...
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" <no**@none.comw rote in message
news:f0******** *@newsfeed.th.i fl.net...
>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


Apr 25 '07 #5

"Chris Nahr" <di******@kynos arges.dewrote in message
news:td******** *************** *********@4ax.c om...
On Wed, 25 Apr 2007 10:43:49 +0100, "Mantorok" <no**@none.comw rote:
>>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
Apr 25 '07 #6
On Wed, 25 Apr 2007 14:54:33 +0100, "Mantorok" <no**@none.comw rote:
>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
Apr 25 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2313
by: Job Lot | last post by:
How can I terminate console application in Try…Catch…Finally…End Try block so that code in Finally gets executed. If I use End statement Finally does not get executed. Following is my code written in Console Application. Module Module1 Sub Main() Call Testing()
0
2025
by: Bryan Olson | last post by:
New and improved! Love Python's stack-tracing error messages, but hate the way GUI applications throw the messages away and crash silently? Here's a module to show Python error messages that would otherwise be lost in console-less programs. Graphical applications should not require console windows, but they do need a workable destination for sys.stderr.
17
4214
by: MumboJumbo | last post by:
Hi I have a really basic question hopefully some can help me with: Can you write a (i.e. one) C# project that works from the cmd line and gui? I seems if i write a GUI app it can't write to console using System.Console.WriteLine if thge project has its "Output Type" to "Windows Application". However I can write to stdio if i set output type to "Console Application". When I do this I unfortunately get a "console box" as well
3
1961
by: Dean Slindee | last post by:
I have a exception handling class that could be called from either a windows project app or a console project app. Is there any way for this class to determine which type of app called it without sending an window/console parameter from either app? Thanks, Dean Slindee
5
6981
by: Nak | last post by:
Hi there, I have a very simple console application that I'm trying to handle the thread exception on, as I understand it there is no Application object available to a console application, so I can't use this. Instead you need to use "Thread.GetAppDomain.UnhandledException", this "works" to a certain extent but from the look if it you merely get added to a chain of event handlers, and the runtime is still above you, so I can't use this...
0
4695
by: Mythran | last post by:
I can draw onto the console window where I want using a mixture of API calls and the System.Drawing namespace (.Net 1.1). I am trying to install hooks for the window to catch a resize or another message so that when the console window gets redrawn, I can repaint what I need to on this window. So far, no luck. First I install the hook by calling the SetWindowsHookEx passing the type WH_CALLWNDPROC, a delegate for the HOOKPROC param,...
1
2037
by: John Wright | last post by:
I am running a console application that connects to an Access database (8 million rows) and converts it to a text file and then cleans and compacts the database. When it runs I get the following error: The CLR has been unable to transition from COM context 0x1a2008 to COM context 0x1a2178 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long...
0
3457
by: asadikhan | last post by:
I need to call a console app (dtexec) from a windows service in a client/server architecture. I have the application setup so that the client application is called with a package name, which makes a call to a dll on the remote server. I have read up on this on the web and I know that you can't run a GUI app from within windows service, but apparently console apps are ok. I am trying exactly that but it's not working. Here is my code: ...
0
2059
by: Stephen Thomas | last post by:
Hi there I wonder if any one has encountered this problem or can suggest what is wrong. I am trying the a procedure from the msn site but get the following message: Error 1 The type or namespace name 'LiveSearch' does not exist in the namespace 'ConsoleSampleWebSearch' (are you missing an assembly reference?) C:\Documents and Settings\Compaq\Local Settings\Application Data\Temporary Projects\ConsoleSampleWebSearch\Program.cs 13 30...
0
8454
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8878
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8785
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8560
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7389
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5671
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.