473,382 Members | 1,717 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,382 software developers and data experts.

Event log for Windows Service app exceptions -- need better diagnostics

SDS
VS 2005 / .NET 2.0.50727 (Sept. CTP)

I've got a Windows Service application that I've pushed out to a few
other workstations. There is an unhandled except occurring somewhere
in the application at some point, but I can't debug it because the
diagnostic info written to the event log is nearly worthless. Here's
what I am getting:

EventType clr20r3, P1 myservice.exe, P2 0.7.0.19863, P3 435a627e, P4
myservice, P5 0.7.0.19859, P6 435a6276, P7 325, P8 42, P9
system.nullreferenceexception, P10 NIL.

How can I get more verbose diagnostics in the event log, including the
stack trace?

TIA

Nov 17 '05 #1
8 5775
how about you add LOGGING to your application and LOG information that is
important...

"SDS" <ss*******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
VS 2005 / .NET 2.0.50727 (Sept. CTP)

I've got a Windows Service application that I've pushed out to a few
other workstations. There is an unhandled except occurring somewhere
in the application at some point, but I can't debug it because the
diagnostic info written to the event log is nearly worthless. Here's
what I am getting:

EventType clr20r3, P1 myservice.exe, P2 0.7.0.19863, P3 435a627e, P4
myservice, P5 0.7.0.19859, P6 435a6276, P7 325, P8 42, P9
system.nullreferenceexception, P10 NIL.

How can I get more verbose diagnostics in the event log, including the
stack trace?

TIA

Nov 17 '05 #2
SDS
How about staying on topic?

Nov 17 '05 #3
He is. Services in .NET do not automatically log exceptions when they
are thrown. It's just not there.

You need to write it yourself. To that end, the ServiceBase class
assists you by providing an EventLog property where the log is set to the
application log, and the source is set to what is returned by the
ServiceName property.

You can write up a few try/catch blocks, and then write the exception to
the event log, and it should give you the information you want.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SDS" <ss*******@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
How about staying on topic?

Nov 17 '05 #4
SDS
Thanks for the useful response, Nicholas. I wish all replies in
newsgroups could be as helpful as yours, but then again it's clear you
know what you are talking about.

Admittedly, I am being lazy at this point mostly due to the amount of
code, threading, and the fact that my service is in another AppDomain
from where the exception is occurring. It's just going to take me
forever to get all of the handling in place. That and I could've sworn
that .NET will write out stack trace debug info to the event log for
unhandled exceptions...

I wish there was a Service.Error global event handler simliar to
ASP.NET's... =(

Nov 17 '05 #5
I'm kind of confused by the following statement:

and the fact that my service is in another AppDomain from where the
exception is occurring

Are you saying that you are creating another app domain in your service,
and the exception is happening there? If this is the case, then the app
domain is still in the boundary of your service (or at least the CLR that is
loaded in the process of your service). All you have to do is marshal the
instance of the service to your new app domain, and you can log the events
in the event log from the new app domain.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"SDS" <ss*******@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Thanks for the useful response, Nicholas. I wish all replies in
newsgroups could be as helpful as yours, but then again it's clear you
know what you are talking about.

Admittedly, I am being lazy at this point mostly due to the amount of
code, threading, and the fact that my service is in another AppDomain
from where the exception is occurring. It's just going to take me
forever to get all of the handling in place. That and I could've sworn
that .NET will write out stack trace debug info to the event log for
unhandled exceptions...

I wish there was a Service.Error global event handler simliar to
ASP.NET's... =(

Nov 17 '05 #6
SDS
Yeah, you are totally correct there (except I don't think you can
marshal ServiceBase, but I do already have a class that is marshaled
for the purpose of connecting the domains), it's just one more thing to
deal with in the process of trying to track down one bug in a very
short period of time.

Always in a big damn hurry. Know what I mean?

Nov 17 '05 #7
SDS,

Why not? ServiceBase derives from Component, which derives from
MarshalByRefObject, which means that you can marshal a reference into the
new app domain, and then have it call back into the app domain the service
started in.

However, this can have performance ramifications. You might be better
off having an event of some sort be fired, or making a call to your
ServiceBase-derived class on a method you define, which will indicate what
happens, and then you can do the work in the app domain of your service.

Oh, EventLog derives from Component as well, so you can marshal that by
reference across the app domain boundary as well.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SDS" <ss*******@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Yeah, you are totally correct there (except I don't think you can
marshal ServiceBase, but I do already have a class that is marshaled
for the purpose of connecting the domains), it's just one more thing to
deal with in the process of trying to track down one bug in a very
short period of time.

Always in a big damn hurry. Know what I mean?

Nov 17 '05 #8
SDS
I'm not sure, maybe you can, but at some point I made the decision to
not marshal the ServiceBase across AppDomains. Anyhow, like I said, I
have a class whose purpose is nothing other than to act as the
connector between domains, and it is this object that is marshaled.
I've added an EventLog member to this class and am now in the process
of setting up exception handling.

Nov 17 '05 #9

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

Similar topics

3
by: Simon Harvey | last post by:
Hi, Does anyone know of the top of their head, how I would add an entry to the event logs in XP/2000 machines? Thanks all Simon
5
by: Dhilip Kumar | last post by:
Hi All, I'm writing a Windows Service app using C#. I need to read some configuration settings before the service starts up. These settings will be used by the service in its operation. ...
29
by: Patrick | last post by:
I have the following code, which regardless which works fine and logs to the EventViewer regardless of whether <processModel/> section of machine.config is set to username="SYSTEM" or "machine" ...
4
by: Kristof Despiere | last post by:
Suppose you have one domain, filled with a couple of users. What needs to be done now is I need to start a windows application from a webform by pressing a button on the webform (for example). ...
4
by: Aaron Hackney | last post by:
Hello. I am writing a service that I would like to have write access to the Application event log. Since the service is running as a system account, it would appear that I do not have access....
4
by: Guy Noir | last post by:
Hello. OK, Thanks to the help I have the remote debugging worked out. Here is my next hurdle. I have a service that is supposed to be catching Event Log written events. ...
3
by: clsmith66 | last post by:
I hope this is just something stupid I'm missing and someone can easily point out my error. I'm trying to do a few turorials on windows services, and the couple I found so far just create an event...
6
by: JeffDotNet | last post by:
Writing to a registered source in the Application event log I have an asp.net framework 2.0 app that I created on a winxp machine and now I am deploying it to IIS6 on a win server2003 machine. ...
1
by: chitra g | last post by:
Hi, I tried all the options below but did not work. Your suggestions please.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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...

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.