我在TeamCity代理上運行計算模擬器時遇到問題,作爲與xunit進行集成測試的配置項過程的一部分。 我正在使用以下代碼來啓動模擬器並在執行我的Xunit測試時部署我的實例。在TeamCity代理上運行Azure計算仿真器
ExecuteCsrunWith(serviceDirectory + " " + configurationFile);
private ProcessExecutionResult ExecuteCsrunWith(string argument)
{
var result = new ProcessExecutionResult();
using (var process = new Process())
{
process.StartInfo = new ProcessStartInfo(PathToCsrun, argument)
{
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
};
process.Start();
result.Output = process.StandardOutput.ReadToEnd();
result.Error = process.StandardError.ReadToEnd();
process.WaitForExit();
Log(result.Output);
Log(result.Error);
}
return result;
}
測試不工作,我有這樣的錯誤在事件日誌中:
應用:csmonitor.exe Framework版本:v4.0.30319 說明:該工藝由於終止的未處理的異常。 異常信息:System.InvalidOperationException Stack: at System.Windows.Forms.MessageBox.ShowCore(System.Windows.Forms.IWin32Window,System.String,System.String,System.Windows.Forms.MessageBoxButtons,System.Windows。 Forms.MessageBoxIcon,System.Windows.Forms.MessageBoxDefaultButton,System.Windows.Forms.MessageBoxOptions,Boolean) at System.Windows.Forms.MessageBox.Show(System.String,System.String,System.Windows.Forms.MessageBoxButtons, System.Windows.Forms.MessageBoxIcon) 在Microsoft.ServiceHosting.Tools.CloudServicesMonitor.Program.Main(System.String [])
跟:
錯誤的應用程序名:csmonitor.exe,版本:2.4.6489.1,時間戳:0x53bdc3cc 錯誤模塊名稱:KERNELBASE.dll,版本:6.2.9200.16864,時間戳:0x531d34d8 異常代碼:0xe0434352 故障偏移: 0x0000000000047b8c 出錯進程ID:0xe98 錯誤應用程序啓動時間:0x01cff4c9c18a8431 錯誤應用程序路徑:C:\ Program Files文件\微軟的SDK \ Azure的\模擬器\ csmonitor.exe 錯誤模塊路徑:C:\ WINDOWS \ SYSTEM32 \ KERNELBASE.dll 報告ID:2321e30b-60bd-11e4-9406-00155dfd9db8 錯誤包全名: 錯誤包相關應用程序ID:
我需要使用UseShellExecute =假,因爲我需要重定向和讀取輸出。