The service installs correctly but when attempting to start it via net start
or from the services window it doesn't start at all, not even getting to the OnStart
handler.
If I use an administrator account, the service starts and works correctly. This seems to suggest something in the service requires admin privileges but this is purely an on-demand style service with nothing executing until requested. With this type of service I'd assume that is should at least start and then fail later when a request is made to it that requires admin privileges?
It's impossible to debug as I can't even get it to start and nothing is appearing on the event logs apart from an Information log stating that the service stopped. There's too much code in the service to add it all here but the entry point is a fairly standard Unity style service:
partial class MyServiceHost : UnityServiceBase
{
private Bootstrapper _bootstrapper;
public MyServiceHost()
{
InitializeComponent();
}
protected override void OnStart( string[] args )
{
TextWriter tw = new StreamWriter( "ServiceTestLog.txt" );
tw.Write( "Date: " + DateTime.Now + "\n" );
try
{
base.OnStart( args );
_bootstrapper = new Bootstrapper( UnityContainer );
_bootstrapper.Run();
}
catch ( Exception ex )
{
tw.Write( ex.ToString() );
}
tw.Close();
}
protected override void OnStop()
{
_bootstrapper.Teardown();
base.OnStop();
}
}
For business reasons I can't just make the user account it uses an administrator so I'd appreciate any suggestions on how to fix this issue.
Writing to "ServiceTestLog.txt" may require local admin rights.