Hi all,
You must be getting fairly sick of me by now! But anyway:
I've deployed my service and its working fine. Its currently deployed under the 'Local System' account. However, I now need to change this to work under a speciific user account, but when I build my service with that account set, the Opening of the Service Host just sits and doesn't appear to return. This also happens with other service account settings, i.e. Local Service.
The reason I know its not returning is my code outputs to a text file either side of the call to myServiceHost.Open(). When in 'Local System' I get 2 lines written to the text file, when in 'User account' I only get the first line.
Anybody got any ideas? Either to resolve the issue, or where to start debugging?
Cheers,
Greg
Loading
GregPosted Nov 14, 2007, 9:36 AM
Thanks again for the reply.
PS. I replied to this message and its gone to cyberspace somewhere - or somewhere random on the forum - not quite sure how that happened!
Cheers,
Greg
Scott LyslePosted Nov 14, 2007, 8:48 AM
First, does the account have read/write access to the folder where the text is written; if not it has to have that. If the folder you are writing to is on a different machine, then you will need to make sure that account exists on that machine and that the folder has been given read/write access to that account. When crossing domains, I have had better luck by setting up a virtual directory pointing to the folder and then allowing the service to access that folder as a virtual directory. Of course the permissions issues still exist and the virtual directory's permissions need to also be set up to allow read/write access to the folder but it is less messy than mapping drives and what not, your service can then access the folder using something like this:
\\127.0.0.1\SOMEFOLDER\STATUS_REPORTS\
As far as debugging goes, are you trapping and reading your errors? A bit of code such as this can be used to write the errors to the event log; at that you should be able to see exactly what is failing.
public bool WriteToEventLog( string entry, string appName, EventLogEntryType eventType, string logName) { EventLog objEventLog = new EventLog(); try { //Register the Application as an Event Source if (!EventLog.SourceExists(appName)) { EventLog.CreateEventSource(appName, logName); } // log the entry objEventLog.Source = appName; objEventLog.WriteEntry(entry, eventType); return true; } catch { return false; } }You could then call this in a catch block using something like this:
catch (Exception ex) { WriteToEventLog(ex.Message + "::" + ex.StackTrace, "Your.Windows.Service", EventLogEntryType.Error, "Your.Windows.Service"); }