Running as service

  • Thread starter Thread starter 031278
  • Start date Start date
0

031278

Hello,

I am trying to run a process continuously as a service. The process is
to Read from a PLC and write it into a text file. But it does not work
I dont know where the bug exists as debug is not allowed for a window
service project. Same code if i put in a form and run as windows
application it works. so please help me what difference it must be
having running as service and running as application.

thanks in advance

s031278
 
031278 said:
Hello,

I am trying to run a process continuously as a service. The process is
to Read from a PLC and write it into a text file. But it does not work
I dont know where the bug exists as debug is not allowed for a window
service project. Same code if i put in a form and run as windows
application it works. so please help me what difference it must be
having running as service and running as application.

thanks in advance

You can attach the debugger to a Service project's code. If I recall, you
can't debug the code on the OnStart and OnStop events, the last time I
looked.

http://aspalliance.com/1316_Working_with_Windows_Service_Using_Visual_Studio_2005
 
031278 said:
I am trying to run a process continuously as a service. The process is
to Read from a PLC and write it into a text file. But it does not work
I dont know where the bug exists as debug is not allowed for a window
service project.

Of course it is, you just can't modify the code while you're debugging.

Start the service, then attach the IDE to the running process and away
you go. If you think there's a problem in OnStart then add a fairly
hefty Sleep() call as the first statement to give you time to attach the
debugger.
Same code if i put in a form and run as windows
application it works. so please help me what difference it must be
having running as service and running as application.

They run in different user and security contexts.
For example, if the service runs as the Local System account, your
service won't know anything about the network.

HTH,
Phill W.
 
Back
Top