472,783 Members | 938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,783 software developers and data experts.

Windows Service hangs

I have a Windows Service in C# talking to a serial port and using Remoting.
It also uses several COM objects. On customer's computer the service will
occassionally hang somewhere - the service still shows on a Task Manager
list. In Services it says it is still running. However there is no way to
stop it other than by rebooting the whole computer. No exception (including
non-CLS) is ever generated. I added a separate System.Timers.Timer which
detects that the main thread stopped working. I was trying to stop it by
using System.ServiceProcess.ServiceController.Stop() which didn't work. I
tried to do process.Kill() which also doesn't work (and no exception). Is
there a bug in framework somewhere. I don't even hope to find out why it
hangs but if I could just kill it that would solve the problem since I have
another Service which would bring it up. I'll be greatful for any ideas.
Kris.
Nov 17 '05 #1
4 8911

Does your application "hang" when you run it as an application?

Whenever I write a windows service application, there is a core section
which exposes start and stop methods which exist in an assembly (DLL). From
here I can apply any front end I like, whether it be windows service,
windows dialog, or a console application.
While doing any sort of debugging information, I flood the area I'm not sure
about with Console.Writeline(...) calls so that the program flow can be
easily traced, with details of relevant variables. In this case it would be
worth checking the status of your references to your COM objects. Are you
listening to a serial port or sending data to it?

From here it seems unlikely it's the "windows service" part of the
application that's causing the freeze.

"Kris" <Kr**@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...
I have a Windows Service in C# talking to a serial port and using Remoting.
It also uses several COM objects. On customer's computer the service will
occassionally hang somewhere - the service still shows on a Task Manager
list. In Services it says it is still running. However there is no way to
stop it other than by rebooting the whole computer. No exception
(including
non-CLS) is ever generated. I added a separate System.Timers.Timer which
detects that the main thread stopped working. I was trying to stop it by
using System.ServiceProcess.ServiceController.Stop() which didn't work. I
tried to do process.Kill() which also doesn't work (and no exception). Is
there a bug in framework somewhere. I don't even hope to find out why it
hangs but if I could just kill it that would solve the problem since I
have
another Service which would bring it up. I'll be greatful for any ideas.
Kris.

Nov 17 '05 #2
Dan,
Thanks for your reply. To answer your questions I both listen and talk to
the serial port and I actually have a GUI app that uses the same code as my
Service. I never ran it long enough to make it crash though. My crash
(freeze) occurs very infrequently (recently it was 6 weeks) and only on one
particular computer. Actually in the past it was freezing every few hours
also. Maybe I should have changed the emphasis of my question to how to kill
the frozen service rather than why it freezes. If I can kill it then it will
be restarted automatically by another service. Right now I can't kill it by
using Process.Kill() nor manually from the command line nor through the Task
Manager nor can I stop it from the Services. The only way to stop it is to
reboot the computer. Apparently it is messed up big time. No exceptions are
ever being caught. Thanks again.
Kris.

"Dan Bass" wrote:

Does your application "hang" when you run it as an application?

Whenever I write a windows service application, there is a core section
which exposes start and stop methods which exist in an assembly (DLL). From
here I can apply any front end I like, whether it be windows service,
windows dialog, or a console application.
While doing any sort of debugging information, I flood the area I'm not sure
about with Console.Writeline(...) calls so that the program flow can be
easily traced, with details of relevant variables. In this case it would be
worth checking the status of your references to your COM objects. Are you
listening to a serial port or sending data to it?

From here it seems unlikely it's the "windows service" part of the
application that's causing the freeze.

"Kris" <Kr**@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...
I have a Windows Service in C# talking to a serial port and using Remoting.
It also uses several COM objects. On customer's computer the service will
occassionally hang somewhere - the service still shows on a Task Manager
list. In Services it says it is still running. However there is no way to
stop it other than by rebooting the whole computer. No exception
(including
non-CLS) is ever generated. I added a separate System.Timers.Timer which
detects that the main thread stopped working. I was trying to stop it by
using System.ServiceProcess.ServiceController.Stop() which didn't work. I
tried to do process.Kill() which also doesn't work (and no exception). Is
there a bug in framework somewhere. I don't even hope to find out why it
hangs but if I could just kill it that would solve the problem since I
have
another Service which would bring it up. I'll be greatful for any ideas.
Kris.


Nov 17 '05 #3

if it's on a windows 2000+ machine there's a handy utility called "kill". If
you go to the command prompt and type "kill /f <processName>" it should nuke
it.

Better to find a fix to a problem than a work around though.
Check the Nt Event log at the time of the freeze, for example.
Was there other activity going on at the same time on the machine (i.e. low
on resources).
Are the ports your using being released properly?
.... and so the list of questions can go on.
"Kris" <Kr**@discussions.microsoft.com> wrote in message
news:B5**********************************@microsof t.com...
Dan,
Thanks for your reply. To answer your questions I both listen and talk to
the serial port and I actually have a GUI app that uses the same code as
my
Service. I never ran it long enough to make it crash though. My crash
(freeze) occurs very infrequently (recently it was 6 weeks) and only on
one
particular computer. Actually in the past it was freezing every few hours
also. Maybe I should have changed the emphasis of my question to how to
kill
the frozen service rather than why it freezes. If I can kill it then it
will
be restarted automatically by another service. Right now I can't kill it
by
using Process.Kill() nor manually from the command line nor through the
Task
Manager nor can I stop it from the Services. The only way to stop it is to
reboot the computer. Apparently it is messed up big time. No exceptions
are
ever being caught. Thanks again.
Kris.

"Dan Bass" wrote:

Does your application "hang" when you run it as an application?

Whenever I write a windows service application, there is a core section
which exposes start and stop methods which exist in an assembly (DLL).
From
here I can apply any front end I like, whether it be windows service,
windows dialog, or a console application.
While doing any sort of debugging information, I flood the area I'm not
sure
about with Console.Writeline(...) calls so that the program flow can be
easily traced, with details of relevant variables. In this case it would
be
worth checking the status of your references to your COM objects. Are you
listening to a serial port or sending data to it?

From here it seems unlikely it's the "windows service" part of the
application that's causing the freeze.

"Kris" <Kr**@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...
>I have a Windows Service in C# talking to a serial port and using
>Remoting.
> It also uses several COM objects. On customer's computer the service
> will
> occassionally hang somewhere - the service still shows on a Task
> Manager
> list. In Services it says it is still running. However there is no way
> to
> stop it other than by rebooting the whole computer. No exception
> (including
> non-CLS) is ever generated. I added a separate System.Timers.Timer
> which
> detects that the main thread stopped working. I was trying to stop it
> by
> using System.ServiceProcess.ServiceController.Stop() which didn't work.
> I
> tried to do process.Kill() which also doesn't work (and no exception).
> Is
> there a bug in framework somewhere. I don't even hope to find out why
> it
> hangs but if I could just kill it that would solve the problem since I
> have
> another Service which would bring it up. I'll be greatful for any
> ideas.
> Kris.


Nov 17 '05 #4
Dan,
Thanks again. In the past I was trying to terminate it by using kill
<processId> from the command line which did not work. Whenever I have a next
chance I will try to use kill /f which will still not fix my problem because
as I mentioned I'm trying to kill it programmatically with no effect and I
don't understand why. Seems like OS somehow lost track of this service. No
messages were reported in the event logs for the time when it crashed. As you
said there are just too many things that can go wrong - serial port, old COM
dlls, remoting. But it work "most" of the time and on all other machines it
works all the time.
Regards, Kris.
"Dan Bass" wrote:

if it's on a windows 2000+ machine there's a handy utility called "kill". If
you go to the command prompt and type "kill /f <processName>" it should nuke
it.

Better to find a fix to a problem than a work around though.
Check the Nt Event log at the time of the freeze, for example.
Was there other activity going on at the same time on the machine (i.e. low
on resources).
Are the ports your using being released properly?
.... and so the list of questions can go on.
"Kris" <Kr**@discussions.microsoft.com> wrote in message
news:B5**********************************@microsof t.com...
Dan,
Thanks for your reply. To answer your questions I both listen and talk to
the serial port and I actually have a GUI app that uses the same code as
my
Service. I never ran it long enough to make it crash though. My crash
(freeze) occurs very infrequently (recently it was 6 weeks) and only on
one
particular computer. Actually in the past it was freezing every few hours
also. Maybe I should have changed the emphasis of my question to how to
kill
the frozen service rather than why it freezes. If I can kill it then it
will
be restarted automatically by another service. Right now I can't kill it
by
using Process.Kill() nor manually from the command line nor through the
Task
Manager nor can I stop it from the Services. The only way to stop it is to
reboot the computer. Apparently it is messed up big time. No exceptions
are
ever being caught. Thanks again.
Kris.

"Dan Bass" wrote:

Does your application "hang" when you run it as an application?

Whenever I write a windows service application, there is a core section
which exposes start and stop methods which exist in an assembly (DLL).
From
here I can apply any front end I like, whether it be windows service,
windows dialog, or a console application.
While doing any sort of debugging information, I flood the area I'm not
sure
about with Console.Writeline(...) calls so that the program flow can be
easily traced, with details of relevant variables. In this case it would
be
worth checking the status of your references to your COM objects. Are you
listening to a serial port or sending data to it?

From here it seems unlikely it's the "windows service" part of the
application that's causing the freeze.

"Kris" <Kr**@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...
>I have a Windows Service in C# talking to a serial port and using
>Remoting.
> It also uses several COM objects. On customer's computer the service
> will
> occassionally hang somewhere - the service still shows on a Task
> Manager
> list. In Services it says it is still running. However there is no way
> to
> stop it other than by rebooting the whole computer. No exception
> (including
> non-CLS) is ever generated. I added a separate System.Timers.Timer
> which
> detects that the main thread stopped working. I was trying to stop it
> by
> using System.ServiceProcess.ServiceController.Stop() which didn't work.
> I
> tried to do process.Kill() which also doesn't work (and no exception).
> Is
> there a bug in framework somewhere. I don't even hope to find out why
> it
> hangs but if I could just kill it that would solve the problem since I
> have
> another Service which would bring it up. I'll be greatful for any
> ideas.
> Kris.


Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jacob Crossley | last post by:
Hello all. We have about 10 Window's services that we wrote in c#. We use them to process row's that we have queued up in various SQL tables. The services seem to hang at least once in any given...
5
by: Andrea Vincenzi | last post by:
Help me please, I'm totally stuck! My Visual Studio 2003 debugger stopped working after I installed Windows XP Service Pack 2. Here is what happens (with any project, even a "Hello, world"...
4
by: Steven De Smet | last post by:
Hello, This is my first post. I searched on the internet for answers but I was unable to solve my problem. So I hope that you guy's can help me with my VB.NET problem I tried to create a...
7
by: Ashish Khandelwal | last post by:
I have a Windows Service in C# talking to a serial port and using Remoting. It also uses several COM objects. On server the service will occassionally hang somewhere - the service still shows on a...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.