473,624 Members | 2,453 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(serve r, port);
} catch (SocketExceptio n e) {
// probably, the server is not running, so start it now!
if (serverProcess != null) {
serverProcess.K ill();
serverProcess = null;
}
serverProcess = new Process();
serverProcess.S tartInfo.FileNa me = exePath;
serverProcess.S tartInfo.Argume nts = "127.0.0.1 13000";
serverProcess.S tartInfo.Window Style = ProcessWindowSt yle.Normal;
serverProcess.S tart();
}
}

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\ASP NET". I have added ASPNET
to the Debugger Users group - but that doesn't seem to change anything.

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

Any ideas how to solve this?

kind regards,
david

Nov 18 '05 #1
3 1434
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(serve r, port);
} catch (SocketExceptio n e) {
// probably, the server is not running, so start it now!
if (serverProcess != null) {
serverProcess.K ill();
serverProcess = null;
}
serverProcess = new Process();
serverProcess.S tartInfo.FileNa me = exePath;
serverProcess.S tartInfo.Argume nts = "127.0.0.1 13000";
serverProcess.S tartInfo.Window Style = ProcessWindowSt yle.Normal;
serverProcess.S tart();
}
}

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\ASP NET". I have added ASPNET
to the Debugger Users group - but that doesn't seem to change anything.

I've also tried it with ProcessWindowSt yle.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.

ProcessStartInf o psi = new ProcessStartInf o("notepad.exe" );
psi.WindowStyle = ProcessWindowSt yle.Hidden;

Process p = new Process();
p.EnableRaising Events = true;
p.Exited += new EventHandler(My Exited);
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
2912
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 starting is that it has a welcome window first which gets displayed and then the real windows after a while,in other words it means that the process name is the same, but the handle I need to retrive is the one from the final window and not the...
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
1775
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 account and the Interact with the Desktop is Checked. Windows media player seems to start but then closes almost immediately. I would appreciate any help. Thanks, Glenn
4
2411
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). The problem is that the user who "owns" the service is always the ASPNET account. That's not good since you don't see the actual application (because it's owned by ASPNET). I've tried changed the processmodel section in the machine.config file to...
3
1959
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 machine.config to operate under other user accounts but our dynamically started process still starts under ASPNET. How do you programatically start a process under a specific Windows User Account? Thanks so much! Christopher
0
1017
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 need to start from my code can takes some times to be really in full real mode. In other words, my main application should continue its next code line while the external process initialise. I have no control of the external process (its an OEM...
4
2941
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), but these child applications must have the same security privileges as the parent starting them. I have created a scheduling app (which will be started by autosys job), which must start child apps when certain criteria are met. The scheduling...
5
4479
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 the Main() function: // if this is not the first instance of this application, exit // immediately. Allow only one instance in the system if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
1
2218
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 start several instances of the same application, like multiple Windows Calculators for instance. We are experiencing difficulties starting applications after a certain number have been started. We changed our app to work as a Console...
1
1847
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(); Problem is: When I close the MFC app if there is an window behind my .NET app it will come to the front leaving my .NET app at the back.
0
8240
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8625
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6111
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.