HighTechTalks DotNet Forums  

Debugging Windows Service

Dotnet General Discussions microsoft.public.dotnet.general


Discuss Debugging Windows Service in the Dotnet General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Derek Hart
 
Posts: n/a

Default Debugging Windows Service - 12-02-2006 , 04:05 PM






As a newbie to Windows Service programming in VB.Net, I need some
clarification. I am writing a Windows Service that works with SQL Server. It
works fine as a console application, but when I run it as a service it is
having problems. I want to be able to debug it, so I placed this code in
the OnStart routine which allows me to break into the code:

System.Diagnostics.Debugger.Launch()
System.Diagnostics.Debugger.Break()

It looks like the only way I am allowed to debug the process is setting the
logon in the service (once it is installed of course) to the Local System
Account and choosing "Allow service to interact with desktop." But it looks
as if Local System does not have access to SQL Server, as I am getting an
"Unable To Connect To Server" error. Should Local System have access?

Derek




Reply With Quote
  #2  
Old   
Kevin Spencer
 
Posts: n/a

Default Re: Debugging Windows Service - 12-02-2006 , 07:04 PM






Check the SQL Server. It depends on how permissions are configured for the
SQL Server.

--
HTH,

Kevin Spencer
Microsoft MVP
Logostician
http://unclechutney.blogspot.com

Parabola is a mate of plane.


"Derek Hart" <derekmhart (AT) yahoo (DOT) com> wrote

Quote:
As a newbie to Windows Service programming in VB.Net, I need some
clarification. I am writing a Windows Service that works with SQL Server.
It works fine as a console application, but when I run it as a service it
is having problems. I want to be able to debug it, so I placed this code
in the OnStart routine which allows me to break into the code:

System.Diagnostics.Debugger.Launch()
System.Diagnostics.Debugger.Break()

It looks like the only way I am allowed to debug the process is setting
the logon in the service (once it is installed of course) to the Local
System Account and choosing "Allow service to interact with desktop." But
it looks as if Local System does not have access to SQL Server, as I am
getting an "Unable To Connect To Server" error. Should Local System have
access?

Derek






Reply With Quote
  #3  
Old   
Coder
 
Posts: n/a

Default Re: Debugging Windows Service - 12-04-2006 , 03:51 AM



If you run under Local System the service will have full permissions over
the machine (higher even than local admin) but it will have no permissions
in SQL Server.

I think what you want to do is run it under the account you need for SQL
access (you didn't say you were using Windows authentication so guessing
here) but make sure that same account is in the Debugger user group
(Computer Management -> Users and Groups -> Groups). Obviously putting it in
the administrators group will eliminate any permissions problems also.

Also, when you debug a service you need to use the attach to process option
in the debugger...

Cheers




"Derek Hart" <derekmhart (AT) yahoo (DOT) com> wrote

Quote:
As a newbie to Windows Service programming in VB.Net, I need some
clarification. I am writing a Windows Service that works with SQL Server.
It works fine as a console application, but when I run it as a service it
is having problems. I want to be able to debug it, so I placed this code
in the OnStart routine which allows me to break into the code:

System.Diagnostics.Debugger.Launch()
System.Diagnostics.Debugger.Break()

It looks like the only way I am allowed to debug the process is setting
the logon in the service (once it is installed of course) to the Local
System Account and choosing "Allow service to interact with desktop." But
it looks as if Local System does not have access to SQL Server, as I am
getting an "Unable To Connect To Server" error. Should Local System have
access?

Derek






Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.