Debugging a Permissions Problem

46 views
Skip to first unread message

Mark Olbert

unread,
Jan 8, 2018, 3:29:24 PM1/8/18
to topshelf-discuss
I've written a Topshelf 4 app which runs fine as a standalone app from the console. I can successfully install it, start it, and stop it as a service...but only if I run it as a particular administrator account on my system (Windows 10 64 bit).

If I try to run it as another user account, even another user account with administrator privileges, I can install it, but it crashes whenever I try to start it, either through the Topshelf-based app itself or the Service Control Manager. Here's the message that appears on the console:

$ CommunityScannerTopShelf.exe start                                                                                                        
[12:16:35 INF] Configuration Result:                                                                                                        
[Success] Name Community Scanner Service                                                                                                    
[Success] ServiceName Community Scanner Service                                                                                             
[12:16:35 INF] Topshelf v4.0.0.0, .NET Framework v4.0.30319.42000                                                                           
[12:16:35 ERR] The service failed to start.                                                                                                 
System.InvalidOperationException: Cannot start service Community Scanner Service on computer '.'. ---> System.ComponentModel.Win32Exception:
 The service did not respond to the start or control request in a timely fashion                                                            
   --- End of inner exception stack trace ---                                                                                               
   at System.ServiceProcess.ServiceController.Start(String[] args)                                                                          
   at System.ServiceProcess.ServiceController.Start()                                                                                       
   at Topshelf.Runtime.Windows.WindowsHostEnvironment.StartService(String serviceName, TimeSpan startTimeOut)                               
   at Topshelf.Hosts.StartHost.Run()                                                                                                        

Obviously, the administrator account which works has some permissions which a newly-created administrator account does not share (the one that works is the primary one I set up when I installed Windows, and the one I use to install everything on the system). But I'm having trouble figuring out where the shortfall in permissions is.

The service app needs to be able to do the following:

  • Read a JSON configuration file from the directory where the exe is located
  • Write log files to Environment.SpecialFolder.LocalApplicationData
  • Interact with a localdb instance of SqlServer
I'm not sure if any of these are the source of the problem. The exception is thrown so early that I don't think any of my code has actually been reached. For example, log messages that should be generated in my service Start( HostControl hostControl) method are not produced, indicating the exception is being thrown before my service is actually being started.

In addition to any suggestions on how to go about resolving this (other than simply using my primary account, which I'd like to avoid), I'm interested in a couple of things.

Can I turn on more in-depth logging within Topshelf? If so, how do I do that?

Is there a utility to compare the permissions of two user accounts under Windows?

Thanx in advance for any help!

- Mark
Reply all
Reply to author
Forward
0 new messages