views:

391

answers:

3

I have a .Net framework 1.1 Windows service that works on one server, but on another the OnStart method is not being called. I have a Trace statement as the first line in the OnStart override and it's not being executed. No exception are thrown and the Windows Service control manager thinks the service has started correctly.

Anyone have an idea what could keep the OnStart method from being called?

Edit: Here's the .config settings for trace output.

<configuration>
    <system.diagnostics>
        <trace autoflush="true" indentsize="4">
            <listeners>
                <add name="LogFileWriter" type="System.Diagnostics.TextWriterTraceListener,System" 
                        initializeData="c:\interface.log" />
            </listeners>
        </trace>
    </system.diagnostics>
</configuration>
A: 

If OnInit is being called, then override it and set the handler yourself

protected override void OnInit(EventArgs e) {
  this.Start += new System.EventHandler(OnStart);
  base.OnInit(e);
}

If OnInit is not called, adding AutoEventWireup = "true" to <%@ Page section might help.

Spikolynn
A: 

If you're writing your trace to an EventLogTrace listener it's possible that the service account on the second machine doesn't have enough rights to access the event log. See my answer to this question:

http://stackoverflow.com/questions/476432/windows-service-running-but-event-logs-not-working#476491

What other activities occur in the OnStart event that suggest the event isn't firing?

Kev
A: 

This ended up being a very obscure issue with a single server that prevented the constructor for the service instance from running.

Rick