Hi Rob
With Windows Services, you absolutely should be building error logging
infrastructure either using the Windows Event Log or by writing to a log
file the actual details of the error message. This way, you'll see the
actual error message & you won't be guessing as to what's going wrong.
To write to the Windows Event Log, your code would be something like:
Try
..connect to db
Catch ex as Exception
EventLog.WriteEntry(ex.Message)
End try
Then, you'd get the full message without running in debug.
Another option is to use the Windows SDK debugger which you attach to the
running service and see real time debugging info. This is worth a play if
you've never done it as it will open up new dev techniques to you (eg
debugging external apps such as sql server) if you take the time.
Running services under LocalSystem is never a good idea, especially when
they need to connect to networked resources but even more so for security
reasons as LocalSystem has more permission than even a local Administrator.
You should configure your service installer to install as something other
than LS...
HTH
Regards,
Greg Linwood
SQL Server MVP
[quoted text, click to view] "Rob Meade" <robb.meade@NO-SPAM.kingswoodweb.net> wrote in message
news:qxWic.1596$kj.12658948@news-text.cableinet.net...
> Hi all,
>
> I have written a small windows service (vb.net) which checks a directory
for
> a new
> file, upon receiving one writes a line to the log file and then copies the
> file (small text file) to SQL server.
>
> I've had a few problems with it today, so have been running it in debug
> mode (visual studio) - when I do so and step through its all perfect - no
> problems at all -
> as soon as I remove the debugger.launch() line and run the service -
whilst
> it doesn't error, the database end seems to fail, ie, no new row is
> written..
>
> Can anyone suggest what might be wrong here? The service is using a
> database connection which specifies the user id and password to use on the
> database, so my initial though of "oh it must be permissions" may well be
> wrong...
>
> The service is running under the LocalSystem account.
>
> If anyone has any ideas I'd love to hear from you...this has gone quite
well
> thus far but cant really run it in debug mode for ever! :o)
>
> Thanks in advance for any help - will post code if applicable.
>
> Regards
>
> Rob
>
>