killing a process in C# web application

G

Guest

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!!!!
 
M

Michael Nemtsev

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
 
T

Tom Porterfield

Rain said:
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?
 
G

Guest

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?
 
T

Tom Porterfield

Rain said:
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?
 
M

Michael Nemtsev

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>---
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
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Rain said:
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.
 
B

Ben Voigt

Rain said:
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(...).Kill

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.
 
G

Guest

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top