2011-12-19 27 views
0

我在plink.exe上使用Process.Start在Linux机器上运行远程调用。这很好,除非在NUnit的环境中运行(我已经尝试了TestDriven.NET和ReSharper的单元测试运行器)。奇怪的Process.Start在NUnit下的行为

在NUnit测试中,该过程似乎立即关闭,而实际上并没有做任何事情,比如某些事情迫使它关闭。

下面是代码,请注意,在控制台应用程序的上下文中,它可以很好地工作。

var processStartInfo = new ProcessStartInfo();   
processStartInfo.FileName = @"D:\Tools\plink\plink.exe"; 
processStartInfo.Arguments = "-ssh #some parameters here#; 
processStartInfo.UseShellExecute = false; 
processStartInfo.RedirectStandardOutput = true; 

var process = new Process(); 

process.StartInfo = processStartInfo; 
process.Start();    
var output = process.StandardOutput.ReadToEnd(); 

回答

1

可能是你忘了:

process.WaitForExit(); 
+0

但如果是需要,我的控制台应用程序就不会工作为好,对不对? – 2012-04-02 06:09:25