473,396 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with Process function - ASP page using C#

Here is my C# code in the ASP.NET page.

public static void DoConvert ( string sFile )
{
string cmd = "foo.exe" ;
string param = " /bar.txt" ;
Process myproc ; // <-- Error here
ProcessStartInfo startInfo = new ProcessStartInfo ( cmd , param ) ;
startInfo.CreateNoWindow = true ;
startInfo.WindowStyle = ProcessWindowStyle.Hidden ;
myproc = Process.Start ( startInfo );
//myproc.WaitForExit () ;
myproc.Close() ;
}

When I run it I get:
Compiler Error Message: CS0246: The type or namespace name 'Process'
could not be found (are you missing a using directive or an assembly
reference?)

I think this is because I need:

using System.ComponentModel;

But I can't figure out where to put it. I've tried several places but
still got the error. Any ideas?

Thanks!

--
http://www.vbmark.com/
A good place to start.
Nov 16 '05 #1
3 6885
vbMark,

You need to add a directive to use the System.Diagnostics namespace in
your page. You can also use the full name of the process and start info
classes, like this:

System.Diagnostics.Process myproc ; // <-- Error here
System.Diagnostics.ProcessStartInfo startInfo = new
System.Diagnostics.ProcessStartInfo ( cmd , param ) ;
startInfo.CreateNoWindow = true ;
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden ;
myproc = System.Diagnostics.Process.Start ( startInfo );

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"vbMark" <no@email.com> wrote in message
news:Xn************************@130.133.1.4...
Here is my C# code in the ASP.NET page.

public static void DoConvert ( string sFile )
{
string cmd = "foo.exe" ;
string param = " /bar.txt" ;
Process myproc ; // <-- Error here
ProcessStartInfo startInfo = new ProcessStartInfo ( cmd , param ) ;
startInfo.CreateNoWindow = true ;
startInfo.WindowStyle = ProcessWindowStyle.Hidden ;
myproc = Process.Start ( startInfo );
//myproc.WaitForExit () ;
myproc.Close() ;
}

When I run it I get:
Compiler Error Message: CS0246: The type or namespace name 'Process'
could not be found (are you missing a using directive or an assembly
reference?)

I think this is because I need:

using System.ComponentModel;

But I can't figure out where to put it. I've tried several places but
still got the error. Any ideas?

Thanks!

--
http://www.vbmark.com/
A good place to start.

Nov 16 '05 #2
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in news:OU**************@tk2msftngp13.phx.gbl:
vbMark,

You need to add a directive to use the System.Diagnostics
namespace in
your page. You can also use the full name of the process and start
info classes, like this:

System.Diagnostics.Process myproc ; // <-- Error here
System.Diagnostics.ProcessStartInfo startInfo = new
System.Diagnostics.ProcessStartInfo ( cmd , param ) ;
startInfo.CreateNoWindow = true ;
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden ;
myproc = System.Diagnostics.Process.Start ( startInfo );

Hope this helps.

Well now I'm getting a different error:

Error saving file: System.ComponentModel.Win32Exception: Access is denied
at System.Diagnostics.Process.StartWithShellExecuteEx (ProcessStartInfo
startInfo) at System.Diagnostics.Process.Start() at
System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at
converter.WebForm1.DoConvert(String sFile) in c:\inetpub\wwwroot
\converter\default.aspx.cs:line 39 at ASP.default_aspx.Button1_Click
(Object Source, EventArgs e) in
http://localhost/converter/default.aspx:line 34

Is this because it can't run an executable or some other reason? Is this
how one is supposed to run an executable at the server?

--
http://www.vbmark.com/
A good place to start.
Nov 16 '05 #3
vbMark,

This is the result of not having sufficient rights. By default, ASP.NET
runs under the ASPNET local account, which has a limited set of rights. If
anything, you need to impersonate a user that has the rights that your
executable needs to operate.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"vbMark" <no@email.com> wrote in message
news:Xn************************@130.133.1.4...
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in news:OU**************@tk2msftngp13.phx.gbl:
vbMark,

You need to add a directive to use the System.Diagnostics
namespace in
your page. You can also use the full name of the process and start
info classes, like this:

System.Diagnostics.Process myproc ; // <-- Error here
System.Diagnostics.ProcessStartInfo startInfo = new
System.Diagnostics.ProcessStartInfo ( cmd , param ) ;
startInfo.CreateNoWindow = true ;
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden ;
myproc = System.Diagnostics.Process.Start ( startInfo );

Hope this helps.

Well now I'm getting a different error:

Error saving file: System.ComponentModel.Win32Exception: Access is denied
at System.Diagnostics.Process.StartWithShellExecuteEx (ProcessStartInfo
startInfo) at System.Diagnostics.Process.Start() at
System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at
converter.WebForm1.DoConvert(String sFile) in c:\inetpub\wwwroot
\converter\default.aspx.cs:line 39 at ASP.default_aspx.Button1_Click
(Object Source, EventArgs e) in
http://localhost/converter/default.aspx:line 34

Is this because it can't run an executable or some other reason? Is this
how one is supposed to run an executable at the server?

--
http://www.vbmark.com/
A good place to start.

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Brandon Hoppe | last post by:
I'm trying to change the src of an ilayer in the parent document from a link inside the ilayer. I'm not able to get it to work. All that happens is Netscape 4 crashes. This is for Netscape 4 only....
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
2
by: Chris | last post by:
Hi, I have a Javascript function that loads a page with a progress bar for long process. The progress bar is a gif animation and for some reason it the animation is stuck when the function is...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
14
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So,...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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
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
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,...

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.