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

killing a process in C# web application

P: n/a
Does anyone know how i can kill a process using C#? im developing an asp.net
web application using C# and the asp.net process doesnt die even if the
application has already exited. So i need to kill the process someone.. does
anyone know the code for this? thank you so much in advance!!!!
Jun 14 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hello RaiN,

Do you want kill w3w.exe forcely? How come?
What's the reason?

ASP.net app is hosted into IIS in separate domain and thus you can have several
iis hosted processes on your machine

R> Does anyone know how i can kill a process using C#? im developing an
R> asp.net web application using C# and the asp.net process doesnt die
R> even if the application has already exited. So i need to kill the
R> process someone.. does anyone know the code for this? thank you so
R> much in advance!!!!
R>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Jun 14 '06 #2

P: n/a
Rain wrote:
Does anyone know how i can kill a process using C#? im developing an
asp.net web application using C# and the asp.net process doesnt die even
if the application has already exited. So i need to kill the process
someone.. does anyone know the code for this? thank you so much in
advance!!!!


It is normal for the asp worker process to continue running after the
application has exited, this is how it is designed to work. Why do you
think you need to kill the process?
--
Tom Porterfield

Jun 14 '06 #3

P: n/a
Bacuase i always get an error telling me that only one socket can be used or
something like that even if i already restarted the application. All my
sockets are killed b4 the application exits. The error message does not
appear when i manually kill the process.

I just need to kill the process b4 i exit so the next time i start my pp, i
wont be encountering the error. Does anyone know the C# CODE for it?

"Tom Porterfield" wrote:
Rain wrote:
Does anyone know how i can kill a process using C#? im developing an
asp.net web application using C# and the asp.net process doesnt die even
if the application has already exited. So i need to kill the process
someone.. does anyone know the code for this? thank you so much in
advance!!!!


It is normal for the asp worker process to continue running after the
application has exited, this is how it is designed to work. Why do you
think you need to kill the process?
--
Tom Porterfield

Jun 14 '06 #4

P: n/a
Rain wrote:
Bacuase i always get an error telling me that only one socket can be used
or something like that even if i already restarted the application. All my
sockets are killed b4 the application exits. The error message does not
appear when i manually kill the process.

I just need to kill the process b4 i exit so the next time i start my pp,
i wont be encountering the error. Does anyone know the C# CODE for it?


What is the exact name of the process you think you need to kill?
--
Tom Porterfield

Jun 14 '06 #5

P: n/a
Hello RaiN,

Killing the hosted process isn't normal situation, you need to treat with
you sockets neatly without brutal problem-solving

R> Bacuase i always get an error telling me that only one socket can be
R> used or something like that even if i already restarted the
R> application. All my sockets are killed b4 the application exits. The
R> error message does not appear when i manually kill the process.
R>
R> I just need to kill the process b4 i exit so the next time i start my
R> pp, i wont be encountering the error. Does anyone know the C# CODE
R> for it?
R>
R> "Tom Porterfield" wrote:
R>
Rain wrote:
Does anyone know how i can kill a process using C#? im developing an
asp.net web application using C# and the asp.net process doesnt die
even if the application has already exited. So i need to kill the
process someone.. does anyone know the code for this? thank you so
much in advance!!!!

It is normal for the asp worker process to continue running after the
application has exited, this is how it is designed to work. Why do
you
think you need to kill the process?
--
Tom Porterfield

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Jun 14 '06 #6

P: n/a
Hi,

"Rain" <Ra**@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
Bacuase i always get an error telling me that only one socket can be used
or
something like that even if i already restarted the application. All my
sockets are killed b4 the application exits. The error message does not
appear when i manually kill the process.


Are you opening a listener ?

If you do not post a piece of code, or give more details of what the app
does we cannot help you much.
by the other hand the asp worker process most probably has nothing to do
with your error.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jun 14 '06 #7

P: n/a
"Rain" <Ra**@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
Bacuase i always get an error telling me that only one socket can be used
or
something like that even if i already restarted the application. All my
sockets are killed b4 the application exits. The error message does not
appear when i manually kill the process.

I just need to kill the process b4 i exit so the next time i start my pp,
i
wont be encountering the error. Does anyone know the C# CODE for it?
I'm going to answer your question:
System.Diagnostics.Process.GetProcessById(...).Kil l

But, you should still consider what everyone else is saying. Normally,
there is no reason to kill the ASP.NET worker process. Perhaps you should
build an aspx page that calls AppDomain.Exit(AppDomain.CurrentDomain), which
will kill your assemblies without affecting any other appdomains running in
the shared IIS ASP.NET process.

"Tom Porterfield" wrote:
Rain wrote:
> Does anyone know how i can kill a process using C#? im developing an
> asp.net web application using C# and the asp.net process doesnt die
> even
> if the application has already exited. So i need to kill the process
> someone.. does anyone know the code for this? thank you so much in
> advance!!!!


It is normal for the asp worker process to continue running after the
application has exited, this is how it is designed to work. Why do you
think you need to kill the process?
--
Tom Porterfield

Jun 14 '06 #8

P: n/a
Thanks Ben and everyone for your help and yes im aware of what you all are
saying. I just want to make sure that everythings clean after i exit the
application and before i start the application. Thanks everyone!

"Ben Voigt" wrote:
"Rain" <Ra**@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
Bacuase i always get an error telling me that only one socket can be used
or
something like that even if i already restarted the application. All my
sockets are killed b4 the application exits. The error message does not
appear when i manually kill the process.

I just need to kill the process b4 i exit so the next time i start my pp,
i
wont be encountering the error. Does anyone know the C# CODE for it?


I'm going to answer your question:
System.Diagnostics.Process.GetProcessById(...).Kil l

But, you should still consider what everyone else is saying. Normally,
there is no reason to kill the ASP.NET worker process. Perhaps you should
build an aspx page that calls AppDomain.Exit(AppDomain.CurrentDomain), which
will kill your assemblies without affecting any other appdomains running in
the shared IIS ASP.NET process.

"Tom Porterfield" wrote:
Rain wrote:
> Does anyone know how i can kill a process using C#? im developing an
> asp.net web application using C# and the asp.net process doesnt die
> even
> if the application has already exited. So i need to kill the process
> someone.. does anyone know the code for this? thank you so much in
> advance!!!!

It is normal for the asp worker process to continue running after the
application has exited, this is how it is designed to work. Why do you
think you need to kill the process?
--
Tom Porterfield


Jun 15 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.