469,954 Members | 1,790 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,954 developers. It's quick & easy.

Starting process from ASP.NET application

I'm trying to start a process from an ASP.NET Web application. The
reason I need this is to encapsulate a (unmanaged) DLL that sometimes
crashes. If I run this DLL directly with P/Invoke from within my ASP.NET
application, this sometimes crashes the whole IIS.

So the idea is to have a separate server which accepts requests (via a
socket connection), calls the DLL with the given parameters and returns
the results.

This works well when I start the server from a console, but it needs to
be started automatically from the Web application. Currently, I'm doing
it this way:

Process serverProcess;

Int32 port = 13000;
String server = "127.0.0.1";
for (int i=0; i < 3 && client == null; i++) {
try {
client = new TcpClient(server, port);
} catch (SocketException e) {
// probably, the server is not running, so start it now!
if (serverProcess != null) {
serverProcess.Kill();
serverProcess = null;
}
serverProcess = new Process();
serverProcess.StartInfo.FileName = exePath;
serverProcess.StartInfo.Arguments = "127.0.0.1 13000";
serverProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
serverProcess.Start();
}
}

But this "serverProcess.Start()" doesn't work :-(

I get an error dialog "JIT Debugging", "JIT Debugging failed with the
following error: Zugriff verweigert (access denied)", "JIT Debugging was
initiated by the user account "\myMachine\ASPNET". I have added ASPNET
to the Debugger Users group - but that doesn't seem to change anything.

I've also tried it with ProcessWindowStyle.Hidden - but that doesn't
improve things either...

Any ideas how to solve this?

kind regards,
david

Nov 18 '05 #1
3 1333
I noticed your post went unanswered. Did you resolve this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Holger (David) Wagner" <da***@purple-sunshine.de> wrote in message
news:bv**********@svr7.m-online.net...
I'm trying to start a process from an ASP.NET Web application. The
reason I need this is to encapsulate a (unmanaged) DLL that sometimes
crashes. If I run this DLL directly with P/Invoke from within my ASP.NET
application, this sometimes crashes the whole IIS.

So the idea is to have a separate server which accepts requests (via a
socket connection), calls the DLL with the given parameters and returns
the results.

This works well when I start the server from a console, but it needs to
be started automatically from the Web application. Currently, I'm doing
it this way:

Process serverProcess;

Int32 port = 13000;
String server = "127.0.0.1";
for (int i=0; i < 3 && client == null; i++) {
try {
client = new TcpClient(server, port);
} catch (SocketException e) {
// probably, the server is not running, so start it now!
if (serverProcess != null) {
serverProcess.Kill();
serverProcess = null;
}
serverProcess = new Process();
serverProcess.StartInfo.FileName = exePath;
serverProcess.StartInfo.Arguments = "127.0.0.1 13000";
serverProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
serverProcess.Start();
}
}

But this "serverProcess.Start()" doesn't work :-(

I get an error dialog "JIT Debugging", "JIT Debugging failed with the
following error: Zugriff verweigert (access denied)", "JIT Debugging was
initiated by the user account "\myMachine\ASPNET". I have added ASPNET
to the Debugger Users group - but that doesn't seem to change anything.

I've also tried it with ProcessWindowStyle.Hidden - but that doesn't
improve things either...

Any ideas how to solve this?

kind regards,
david

Nov 18 '05 #2
Alvin Bruney [MVP] wrote:
I noticed your post went unanswered. Did you resolve this issue?


No, unfortunately not :-(
Nov 18 '05 #3
If you are running IIS v6, you should put this application in its own
application pool. However if you are not running IIS6 then you will need to
create an appdomain in your code so that your code can run inside the app
domain. An errant program will explode inside the appdomain and not take
down the appserver. With IIS5, it is still possible to crash the appserver
by the way.

Since the exception is coming from the unmanaged world, you will need to
wrap a try/catch block, that is, no parameters like catch {}

You are missing some stuff in your code. Here is the complete code to spawn
a process
Modify your code and see if this helps.

ProcessStartInfo psi = new ProcessStartInfo("notepad.exe");
psi.WindowStyle = ProcessWindowStyle.Hidden;

Process p = new Process();
p.EnableRaisingEvents = true;
p.Exited += new EventHandler(MyExited);
p.StartInfo = psi;
p.Start();

..... do stuff ...

p.Kill(); // Try killing the process

private void MyExited(object sender, EventArgs e)
{
MessageBox.Show("Exited process");
}

This will run notepad "hidden" (for illustration purposes).. Then p.Kill();
should kill it.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Holger (David) Wagner" <da***@purple-sunshine.de> wrote in message
news:bv**********@svr7.m-online.net...
Alvin Bruney [MVP] wrote:
I noticed your post went unanswered. Did you resolve this issue?


No, unfortunately not :-(

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

By using this site, you agree to our Privacy Policy and Terms of Use.