473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Service Crashing

I ran my service and it crashes everynow and then. The following log is recoreded
in the Application Event viewer

An unhandled win32 exception occurred in XYZService.exe [9204]. Just-In-Time
debugging this exception failed with the following error: Debugger could
not be started because no user is logged on.

Has anyone got any comments?
Dec 10 '07 #1
3 4555
Hi,
>Has anyone got any comments?
Yes,...

Try to debug your service or wrap critical code segments
into a try-catch block and try to find out what makes this
that bad. See here for some VB Example (not different from
C#)

http://www.ondotnet.com/pub/a/dotnet...ggingsvcs.html

You also can post some code here, so that we can
have a look at your code,...

I could not find some error code on my system with "9204".
You can try, maybe you will have that code. Check out
my little Exception Viewer if you like:
http://entwicklung.junetz.de/project...tionViewer.zip

But best would be some code here,...
Regards

Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
Dec 10 '07 #2
...or wrap critical code segments into a try-catch block...

Just to observe that the most pragmatic approach here may actually be
to wrap your main work method[*] in a try/catch, doing some error-
logging in the "catch" (perhaps simply writing the message,
stacktrace, etc to the event-log). I agree that exception handling
(esp. "finally") should be "where necessary" in the code, but this
isn't often a useful debugging tool unless you get lucky.
[*]=since tihs is a service, I'm assuming that you spin up a thread in
the "start"; I mean the method you used for the delegate to start the
thread.

Marc
Dec 10 '07 #3
Oh - and any other thread you start ;-p

Any thread that exits because of an unhandled exception will break
your app; this is a good thing as it almost certainly indicates
instability. If you are using lots of threading, perhaps add your
error-logging method to AppDomain.UnhandledException (noting that
ExceptionObject will almost certainly be an Exception).

A very crude (and untested) implementation is shown below. Note that
you might need your installer to create the named ("MyService") event-
source, otherwise this could iteslf explode.

AppDomain.CurrentDomain.UnhandledException +=
CurrentDomain_UnhandledException;
....
static void CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e) {
Exception ex = e.ExceptionObject as Exception;
if (ex == null) {
string msg; // try to log whatever the heck happened!
try { msg = e.ExceptionObject.ToString(); }
catch { msg = "(unreadable exception)"; }
EventLog.WriteEntry("MyService", msg,
EventLogEntryType.Error);
} else {
// log outermost message and stack-trace
EventLog.WriteEntry("MyService", ex.Message,
EventLogEntryType.Error);
EventLog.WriteEntry("MyService", ex.StackTrace,
EventLogEntryType.Information);
while ((ex = ex.InnerException) != null) { // log
inner exception messages
EventLog.WriteEntry("MyService", ex.Message,
EventLogEntryType.Information);
}
}
}
Dec 10 '07 #4

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

Similar topics

7
by: Mike | last post by:
I want to create a windows service that will monitor another window service. what i need for the service to do is, if a service is stopped I need it to start the service back up example: ...
2
by: Razzie | last post by:
Hey all, I wrote a Windows Service. When I test it on my developement machine (winXP) it works fine. It starts ok, never crashes, etc. When I install the service on another machine (win2000) it...
23
by: Adam Clauss | last post by:
I have a C# Windows Service running as the NetworkService account because it needs to access a network share. As part of the service's initialization, I want the service to terminate, if an...
2
by: m11533 | last post by:
I have written an application that runs as a subprocess of a service, where the service is a .NET C# Windows Service that simply starts the subprocess and then periodically checks that the subprocess...
0
by: Lenny Shprekher | last post by:
We need a suggestion what to do with .NET services (written in earliest 2002 version) hangs without any reason. Starts happen more often recently, so we are guessing and thinking about some...
4
by: jf li | last post by:
I have a Asp.net web application and a Asp.net Web service application. The Web application is using HtmlInputFile to get a 50M size of file selected by end user, read the data of this file and...
17
by: UJ | last post by:
Is there any way for a windows service to start a windows program ? I have a service that will need to restart a windows app if it needs to. TIA - Jeff.
4
by: Shawn Meyer | last post by:
A windows service that I developed is crashing unexpectedly. All the logging/ tracing that I implemented cannot seem to catch the crash. I am using multiple threads in many different areas. In...
4
by: Lenny Shprekher | last post by:
Hi, I have long time ago written windows service (VS2002) which is working fine on Windows 2000 server for 4 years. After installing service on Windows 2003 SP1 service crashing every time with...
9
by: Karthikeyan.T.S | last post by:
Hi, I am getting a error when I try to start a Windows Service. The error is "The XYZ service on local computer started and then stopped.Some services stop automatically if they have no work to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.