473,499 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1426
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
2863
by: serge calderara | last post by:
Dear all, I have an application which is suppose to start another executable process. As soon as that process is running, I need to retrive its handle. The problem of the particular process I am...
7
717
by: Yosh | last post by:
I am developing an application that will stop and start a process on a remote machine. What security rights are needed for my application to be able to do this? Hope this makes sense. Yosh
1
1758
by: Glenn | last post by:
I have used this code successfully in a form application. I tried to add the same code in a service and have not been able to get the application to start. I have the service starting with a local...
4
2399
by: Kristof Despiere | last post by:
Suppose you have one domain, filled with a couple of users. What needs to be done now is I need to start a windows application from a webform by pressing a button on the webform (for example). ...
3
1934
by: Christopher | last post by:
One of our ASP.NET Pages is starting a new Process using the Process object. When the process starts, it is started under the ASPNET User. We tried editing the web.config file and the...
0
1002
by: calderara serge | last post by:
Dear All, I am building an application with VB.Net that is starting an external process from my application code by using the process object. The problem I get is that the application that I...
4
2911
by: Phil Mc | last post by:
Say for example you have a application running on a windows 2003 server (that is on server, not from). This application needs to start child applications (must be stand alone console applications),...
5
4442
by: Benzi Eilon | last post by:
I have written a C# application which should run as a Windows Service. I must avoid having multiple instances of the application on one machine so I inserted the following code at the beginning of...
1
2200
by: mikelujan | last post by:
Hi, Our application starts an external application using System.Diagnostics.Process class and the Start() method, as per code snippet below. This application run as a Windows service, and must...
1
1836
by: ropo | last post by:
I have a .NET 2.0 app that at one point starts an old MFC App through System.Diagnostics.Process.Start from a model form/ I then wait for it to finish by calling StartedProcess.WaitForExit(); ...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7386
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.