By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,124 Members | 1,566 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,124 IT Pros & Developers. It's quick & easy.

why won't my service stay started

P: n/a
it only behaves as expected if i edit the service to run under the system
account and enable the "allow service to interact with desktop" option. if i
run without that enabled or run it under my currently logged on account it
gives an error saying the service started and then stopped right away. i
just created a new vb.net service and put a timer in it and set the interval
and put some code in the Timer1_Elapsed... the timer is just the default
one of type system.timers.timer , is there another type i should be using
here?

also how come when i hit the debug button it tells me you cannot start the
service from the command line or debugger, and if i wait a few seconds
before hitting ok my timer event fires and i can debug it fine?? is there
some other way to debug it properly?

thanks in advance
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Mon, 06 Dec 2004 13:10:18 GMT, "Lance Colton"
<la**********@gmail.nospam> wrote:
it only behaves as expected if i edit the service to run under the system
account and enable the "allow service to interact with desktop" option. if i
run without that enabled or run it under my currently logged on account it
gives an error saying the service started and then stopped right away. i
just created a new vb.net service and put a timer in it and set the interval
and put some code in the Timer1_Elapsed... the timer is just the default
one of type system.timers.timer , is there another type i should be using
here?
What code do you have in the timer?
The most likely thing is that the timer fires and what it does isn't
allowed without desktop interaction
also how come when i hit the debug button it tells me you cannot start the
service from the command line or debugger, and if i wait a few seconds
before hitting ok my timer event fires and i can debug it fine?? is there
some other way to debug it properly?


You can run it from the Service Control Manager and the use "Tools ->
Debug Processes" to attach to it

Vin
Nov 21 '05 #2

P: n/a
code in the timer:

==============
Dim myReader As System.Data.SqlClient.SqlDataReader
SqlConnection1.Open()
SqlCommand1.CommandText = "xxxxxxxxxxxxxxxx"
myReader = SqlCommand1.ExecuteReader()
While myReader.Read()
Debug.WriteLine(myReader.Item(0) & myReader.Item(1) & myReader.Item(2))
End While
myReader.Close()
SqlConnection1.Close()
===============
sure, that debug.writeline stuff isn't going to do anything without the IDE
being open, so you think the exe or windows knew this and 'optimized' my
service by removing the whole timer since it does nothing?

maybe my database connection doesn't work properly with no desktop
interaction and its getting an error and closing right away, or something.

thanks for the info on how to debug it though...

"Vincent Finn" <1@2.com> wrote in message
news:5m********************************@4ax.com...
On Mon, 06 Dec 2004 13:10:18 GMT, "Lance Colton"
<la**********@gmail.nospam> wrote:
it only behaves as expected if i edit the service to run under the system
account and enable the "allow service to interact with desktop" option. if
i
run without that enabled or run it under my currently logged on account it
gives an error saying the service started and then stopped right away. i
just created a new vb.net service and put a timer in it and set the
interval
and put some code in the Timer1_Elapsed... the timer is just the default
one of type system.timers.timer , is there another type i should be using
here?


What code do you have in the timer?
The most likely thing is that the timer fires and what it does isn't
allowed without desktop interaction
also how come when i hit the debug button it tells me you cannot start
the
service from the command line or debugger, and if i wait a few seconds
before hitting ok my timer event fires and i can debug it fine?? is there
some other way to debug it properly?


You can run it from the Service Control Manager and the use "Tools ->
Debug Processes" to attach to it

Vin

Nov 21 '05 #3

P: n/a
code in the timer:

==============
Dim myReader As System.Data.SqlClient.SqlDataReader
SqlConnection1.Open()
SqlCommand1.CommandText = "xxxxxxxxxxxxxxxx"
myReader = SqlCommand1.ExecuteReader()
While myReader.Read()
Debug.WriteLine(myReader.Item(0) & myReader.Item(1) & myReader.Item(2))
End While
myReader.Close()
SqlConnection1.Close()
===============
sure, that debug.writeline stuff isn't going to do anything without the IDE
being open, so you think the exe or windows knew this and 'optimized' my
service by removing the whole timer since it does nothing?

maybe my database connection doesn't work properly with no desktop
interaction and its getting an error and closing right away, or something.

thanks for the info on how to debug it though...

"Vincent Finn" <1@2.com> wrote in message
news:5m********************************@4ax.com...
On Mon, 06 Dec 2004 13:10:18 GMT, "Lance Colton"
<la**********@gmail.nospam> wrote:
it only behaves as expected if i edit the service to run under the system
account and enable the "allow service to interact with desktop" option. if
i
run without that enabled or run it under my currently logged on account it
gives an error saying the service started and then stopped right away. i
just created a new vb.net service and put a timer in it and set the
interval
and put some code in the Timer1_Elapsed... the timer is just the default
one of type system.timers.timer , is there another type i should be using
here?


What code do you have in the timer?
The most likely thing is that the timer fires and what it does isn't
allowed without desktop interaction
also how come when i hit the debug button it tells me you cannot start
the
service from the command line or debugger, and if i wait a few seconds
before hitting ok my timer event fires and i can debug it fine?? is there
some other way to debug it properly?


You can run it from the Service Control Manager and the use "Tools ->
Debug Processes" to attach to it

Vin

Nov 21 '05 #4

P: n/a
On Tue, 07 Dec 2004 09:13:38 GMT, "Lance Colton"
<la**********@gmail.nospam> wrote:
code in the timer:

==============
Dim myReader As System.Data.SqlClient.SqlDataReader
SqlConnection1.Open()
SqlCommand1.CommandText = "xxxxxxxxxxxxxxxx"
myReader = SqlCommand1.ExecuteReader()
While myReader.Read()
Debug.WriteLine(myReader.Item(0) & myReader.Item(1) & myReader.Item(2))
End While
myReader.Close()
SqlConnection1.Close()
===============
sure, that debug.writeline stuff isn't going to do anything without the IDE
being open, so you think the exe or windows knew this and 'optimized' my
service by removing the whole timer since it does nothing?
Doubt if it is allowed do that since it can't tell that the function
calls don't do other things
and if the code was all removed then your service would run perfectly
(doing nothing but still running)
maybe my database connection doesn't work properly with no desktop
interaction and its getting an error and closing right away, or something.


sounds more likely
might be worth rephrasing the question with emphasis on the
SqlDataReader class with no desktop
I have never used it so I can't really offer any suggestions

Vin
Nov 21 '05 #5

P: n/a
On Tue, 07 Dec 2004 09:13:38 GMT, "Lance Colton"
<la**********@gmail.nospam> wrote:
code in the timer:

==============
Dim myReader As System.Data.SqlClient.SqlDataReader
SqlConnection1.Open()
SqlCommand1.CommandText = "xxxxxxxxxxxxxxxx"
myReader = SqlCommand1.ExecuteReader()
While myReader.Read()
Debug.WriteLine(myReader.Item(0) & myReader.Item(1) & myReader.Item(2))
End While
myReader.Close()
SqlConnection1.Close()
===============
sure, that debug.writeline stuff isn't going to do anything without the IDE
being open, so you think the exe or windows knew this and 'optimized' my
service by removing the whole timer since it does nothing?
Doubt if it is allowed do that since it can't tell that the function
calls don't do other things
and if the code was all removed then your service would run perfectly
(doing nothing but still running)
maybe my database connection doesn't work properly with no desktop
interaction and its getting an error and closing right away, or something.


sounds more likely
might be worth rephrasing the question with emphasis on the
SqlDataReader class with no desktop
I have never used it so I can't really offer any suggestions

Vin
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.