[Mono-bugs] [Bug 74067][Maj] New - Microsoft.CSharp.Compiler.Compile() method doesn't redirect stderr

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 24 Mar 2005 11:51:34 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by tmiller@weather.com.

http://bugzilla.ximian.com/show_bug.cgi?id=74067

--- shadow/74067	2005-03-24 11:51:34.000000000 -0500
+++ shadow/74067.tmp.15115	2005-03-24 11:51:34.000000000 -0500
@@ -0,0 +1,121 @@
+Bug#: 74067
+Product: Mono: Class Libraries
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Major
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: tmiller@weather.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Summary: Microsoft.CSharp.Compiler.Compile() method doesn't redirect stderr
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+Using mono-1.1.4:
+
+Microsoft.CSharp.Compiler.Compile() method was changed to read from
+StdError of spawned process.  But the StartInfo.RedirectStdError property
+is not set to true on the mcs process.  This causes the following exception
+to be thrown.
+
+
+Unhandled Exception: System.InvalidOperationException: Standard error has
+not been redirected
+in <0x0003a> System.Diagnostics.Process:get_StandardError ()
+in <0x00038> (wrapper remoting-invoke-with-check)
+System.Diagnostics.Process:get_StandardError ()
+
+
+Adding "mcs.StartInfo.RedirectStdError = true;" fixes the problem.
+
+
+
+Steps to reproduce the problem:
+1. Try to compile using Microsoft.CSharp.Compiler.Compile() method.
+2. 
+3. 
+
+Actual Results:
+Always throws exception.
+
+Expected Results:
+Compiled assembly.
+
+
+How often does this happen? 
+Always.
+
+
+Additional Information:
+
+sample to reproduce:
+
+mcs test.cs -r:cscompmgd
+
+== test.cs ==
+using Microsoft.CSharp;
+using System;
+using System.Collections;
+using System.IO;
+using System.Reflection;
+using System.Text;
+
+
+public class test
+{
+    
+    public static void Main(string[] args)
+    {
+        CompileFile("./ctest.cs");
+    }
+    
+    static public void CompileFile(string fname)
+    {
+        using (StreamReader sr = File.OpenText(fname)) 
+        {
+            // run the compile
+            string assName = fname + ".dll";
+            string s = sr.ReadToEnd();
+            
+            string[] srcs        = new string[]{s};
+            string[] srcFnames   = new string[]{fname};
+            string[] refs        = new string[]{};
+            Hashtable opts       = new Hashtable();
+            
+            opts["target"] = "library";
+            CompilerError[] errors = Compiler.Compile(
+                srcs, srcFnames, assName, refs, opts);
+                
+            // throw exception if errors or warnings
+            if(errors.Length > 0)
+            {
+                StringBuilder sb = new StringBuilder();
+                foreach(CompilerError error in errors)
+                {
+                    sb.Append(error.ToString());
+                }
+                
+                throw new ApplicationException(sb.ToString());
+            }
+            
+        }
+    }
+    
+}
+====
+
+
+suggested patch for 1.1.4 branch:
+
+== patch ==
+102a103
+> 			mcs.StartInfo.RedirectStandardError = true;
+====