Hi
Would suggest that instead of using the process class and
invoking the devenv, u try using the VS.Net object
library. This will help you perform the operations in a
much more controlled way.
regards,
sr
>-----Original Message-----
>Hi,
>
>I'm trying to call devenv.exe (VS.NET 2003) from within a
c# app to
>compile a solution. This works fine when the solution
compiles
>properly, but for some reason I can't seem to get the
output from the
>application back properly when a compilation error occurs.
>
>In the code below the "Error!" prints, but there is no
text
>afterwards, and the application is thrown, but the
standard error
>string is emtpy.
>
>I know the output is definately an error. If I change the
following
>line:
>
>// in the code below its false
>_BuildProcess.StartInfo.UseShellExecute = true;
>
>Then a new command line window appears and the VS.NET
compilation
>error is briefly displayed prior to the window shutting
down.
>Unfortunately I'm unsuccesful in reading the error output
from
>StandardError, which means I can't trap compilation
errors.
>
>Any ideas?
>
>Thanks
>
>- Simon
>
>--------------------
>
>_BuildProcess = new System.Diagnostics.Process();
>_BuildProcess.EnableRaisingEvents = false;
>
>_BuildProcess.StartInfo.UseShellExecute = false;
>_BuildProcess.StartInfo.FileName="devenv";
>_BuildProcess.StartInfo.Arguments = "/rebuild release " +
>solutionFile;
>_BuildProcess.StartInfo.WorkingDirectory = localDirectory;
>_BuildProcess.StartInfo.RedirectStandardError = true;
>_BuildProcess.StartInfo.RedirectStandardOutput = true;
>
>_BuildProcess.Start();
>_BuildProcess.WaitForExit();
>
>Console.WriteLine("Error! " +
>_BuildProcess.StandardError.ReadToEnd());
>_BuildProcess.StandardError.Close();
>
>// Exit code other than zero is an error
>if (0 != _BuildProcess.ExitCode)
> throw new ApplicationException(
> string.Format(
> "Build error - Exit Code: {0}; Error: {1}; Output:
{2};",
> _BuildProcess.ExitCode, _BuildError, _BuildOutput));
>.
>
|