Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. use Process class on Mono?

use Process class on Mono?

Scheduled Pinned Locked Moved C#
helpquestionsysadminlinux
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bug_aonz
    wrote on last edited by
    #1

    I need to ping IP with linux commands "ping xxx.xxx.xxx.xxx" . and run it with Mono on Linux server. Let's see my code... Process P = new Process(); P.StartInfo.CreateNoWindow = true; P.StartInfo.FileName = "ping"; P.StartInfo.RedirectStandardOutput = true; P.StartInfo.Arguments = " 202.57.191.167"; P.Start(); P.WaitForExit(); string output = P.StandardOutput.ReadLine(); while (output != null && output!="") { Console.WriteLine(output); output = P.StandardOutput.ReadLine(); Thread.Sleep(500); } Console.ReadLine();
    Then upload and run it,it throw exception... "Unhandled Exception: System.InvalidOperationException: UseShellExecute must be false when redirecting I/O. at System.Diagnostics.Process.Start_shell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] at System.Diagnostics.Process.Start () [0x00000] at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start () at ProcessLinuxCommands.Program.Main (System.String[] args) [0x00000]" Could u help me what is this bug? Does Mono implement the Process class? thank =)

    S 1 Reply Last reply
    0
    • B bug_aonz

      I need to ping IP with linux commands "ping xxx.xxx.xxx.xxx" . and run it with Mono on Linux server. Let's see my code... Process P = new Process(); P.StartInfo.CreateNoWindow = true; P.StartInfo.FileName = "ping"; P.StartInfo.RedirectStandardOutput = true; P.StartInfo.Arguments = " 202.57.191.167"; P.Start(); P.WaitForExit(); string output = P.StandardOutput.ReadLine(); while (output != null && output!="") { Console.WriteLine(output); output = P.StandardOutput.ReadLine(); Thread.Sleep(500); } Console.ReadLine();
      Then upload and run it,it throw exception... "Unhandled Exception: System.InvalidOperationException: UseShellExecute must be false when redirecting I/O. at System.Diagnostics.Process.Start_shell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] at System.Diagnostics.Process.Start () [0x00000] at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start () at ProcessLinuxCommands.Program.Main (System.String[] args) [0x00000]" Could u help me what is this bug? Does Mono implement the Process class? thank =)

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      How about trying to set the StartInfo.UseShellExecute property to false as the exception message indicates.?


      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

      www.troschuetz.de

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups