[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mono-list
Subject:    Re: [Mono-list] command line apps from ASP.NET
From:       Kornél Pál <kornelpal () hotmail ! com>
Date:       2005-07-22 15:16:18
Message-ID: 00b401c58ed0$56c6ad50$0100a8c0 () kornelpal ! hu
[Download RAW message or body]

> In the second (the C# source for an asp.net page), I am using
>
> GACRead.StartInfo.RedirectStandardOutput = true; To use this,
> UseShellExecute must be false, else the error:
>
> System.InvalidOperationException: UseShellExecute must be false when
> redirecting I/O.

Then you have to specify the shell executable as FileName and the command
line (current FileName + Arguments) as Arguments

>> I think you should put the entire command line to FileName
>> and use UseShellExecute = true (default).
>
> I get the error:
>
> System.ComponentModel.Win32Exception: Cannot find the specified file
>
> If I put the entire command within the FileName (obviously with
> UseShellExecute = false;).

I told you to use UseShellExecute = true, but you used UseShellExecute =
false so it's because of you.:) When UseShellExecute = true shell will be
executed.

As you cannot use UseShellExecute = true with RedirectStandardOutput = true
you have to reproduce what the runtime does.

Look at the source code of
ves_icall_System_Diagnostics_Process_Start_internal in
mono/mono/metadata/process.c

The most important is this:

#ifdef PLATFORM_WIN32
  spath = g_getenv ("COMSPEC");
  shell_args = "/c %s";
#else
  spath = g_getenv ("SHELL");
  shell_args = "-c %s";
#endif

You can get the shell executable from an environment variable and use /c
or -c depending on the platform.

There is nothing in UseShellExecute dependent code that you couldn't
reproduce. And I think you are using Linux only because the command line
itself uses GNU utilities so you don't have to create platform independent
code if you don't need it.

Kornél

_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic