Service fails at startup - need more info

P

Per Bergland

I've got a Windows Service written in .NET (1.1).

It works fine on most machines, but on our external W2KS web server,
with many unnecessary services stopped, the services simply fail to
start at boot time.
The System event log shows that the services didn't start "in a timely
fashion" and the Application event log has one ".Net Framework" event
for each failing service. The text just states that an exception
occurred (and the text "Click OK to continue and Cancel to debug" or
something in that vein), and since I don't even get to the entry point
of my exe, the exception probably occurs at assembly load time, much
like the security exceptions you can get when trying to run an exe from
a network disk in your LAN.

How do I find out what the exception is? Is there a magic flag somewhere
that makes the .NET assembly loader be a little more verbose?
A minidump?

Oh, and once I've logged on to the machine, the services start just
fine, of course.

/Per
 
B

Brandon Potter

Depending on how your service is written, we usually just implement an event
log with our services and a whole lot of Try/Catch statements so that we can
see each component starting up in the event log and see at what step the
exception occurs. When we're trying to debug a service that is supposed to
run without a logged on user we usually have to either go the "log and
try/catch the heck out of it" or "run 'n' hope" method since there's really
no good way to debug it that I know of.

Otherwise I guess you could check out permview.exe to see what permissions
it's requesting.

FWIW,

Brandon
 
P

Per Bergland

Brandon said:
Depending on how your service is written, we usually just implement an event
log with our services and a whole lot of Try/Catch statements so that we can
see each component starting up in the event log and see at what step the
exception occurs. When we're trying to debug a service that is supposed to
run without a logged on user we usually have to either go the "log and
try/catch the heck out of it" or "run 'n' hope" method since there's really
no good way to debug it that I know of.

But all that is undoable since I don't even get to the entry point of
the exe.
I have an eventlog that I have no chance of logging to... (the excellent
log4net, btw - highly recommended).
Just in case log4net is failing I even have an "emergency log" that
simply logs to a text file.
Otherwise I guess you could check out permview.exe to see what permissions
it's requesting.
Hmmm, never used that tool.

I checked the Rotor sources to see if there are any undocumented
switches in <system.diagnostics> for assembly loading, but could find
any BooleanSwitch or TraceSwitch entries outside the known in XmlSerializer.
Does anyone know if there are any machine-settable flags for the PE .NET
assembly loader and exe initializer?

I guess I could write a new service that only tries to load the assembly
of my failing service and see what happens in case noone responds to this...

/Per
 
E

Ethan Shayne

You mentioned that in case log4net fails, you use an alternate file
log.

How do you detect if log4net is failing programmatically? Or do you
just always log to both log4net and this backup log all the time?

Thanks,
Ethan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top