Can't write input to process C# Mono Can't write input to process C# Mono shell shell

Can't write input to process C# Mono


One likely explanation for this error is that the process exited before you're attempting to write to it. I tried this with /bin/date and a legitimate StartInfo.WorkingDirectory and the assembly is /Workspace/export/misc/H.exe. This yields:

Unhandled Exception:System.IO.IOException: Write fault on path /Workspace/export/misc/[Unknown]  at System.IO.FileStream.WriteInternal (System.Byte[] src, Int32 offset, Int32 count) [0x00097] in /Workspace/mono/mcs/class/corlib/System.IO/FileStream.cs:658   at System.IO.FileStream.Write (System.Byte[] array, Int32 offset, Int32 count) [0x000aa] in /Workspace/mono/mcs/class/corlib/System.IO/FileStream.cs:634   at System.IO.StreamWriter.FlushBytes () [0x00043] in /Workspace/mono/mcs/class/corlib/System.IO/StreamWriter.cs:222   at System.IO.StreamWriter.FlushCore () [0x00012] in /Workspace/mono/mcs/class/corlib/System.IO/StreamWriter.cs:203   at System.IO.StreamWriter.Write (System.Char[] buffer) [0x00022] in /Workspace/mono/mcs/class/corlib/System.IO/StreamWriter.cs:351   at System.IO.TextWriter.WriteLine () [0x00000] in /Workspace/mono/mcs/class/corlib/System.IO/TextWriter.cs:257   at X.Main () [0x00066] in /Workspace/export/misc/H.cs:17 

You are getting this every time when you're using an invalid directory in process.StartInfo.WorkingDirectory. There's nothing that can be done about that, though the error message should be made clearer.

Your directory is invalid because of the quotation marks. You also should not concatenate path names the way you did as it makes your application non-portable to non-Unix operating systems. Instead, write it as:

var home = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);process.StartInfo.WorkingDirectory = Path.Combine (home, "pacotes", nome_pacote.Text+"-1.0");

Using Environment.GetFolderPath() makes it easier to run your application on a Mac (where home directories are in /Users/<username> instead of /home/<username>).


One other possibility is that the binary that you're launching is a dangling symlink. Check if the binary exists or is a symlink pointing to a valid binary.


As another response stated "One likely explanation for this error is that the process exited before you're attempting to write to it."

And that was the problem I had -- even after setting the WorkingDirectory as described in the other answer. And in your same situation: C#, Mono, Ubuntu.

Ultimately the solution in my case was to set the Arguments so that the process was not exiting, and was really trying to read input from the StandardInput.