C# ASP.NET アプリケーション内から Win32 コマンド ライン プログラムを実行する方法について読んでいますが、何らかの理由で、以下のコードは実行中に完了せず、無期限にoutput = p.StandardOutput.ReadToEnd();オンラインのままになります。
このコードは、ローカル デバッグ サーバーから (Visual Studio から F5 キーを押して) 実行するとうまく動作しますが、完全な URL (myexample.com/testapp) を介してブラウザーからアクセスすると、デバッガーはoutput=...行を超えて移動しませんでした。
ProcessStartInfo info = new ProcessStartInfo(@"FetchIntranetPageSpecial.exe");
info.Arguments = "hostname";
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
info.RedirectStandardInput = true;
info.CreateNoWindow = true;
Process p = System.Diagnostics.Process.Start(info);
p.Start();
// Capture the output
output = p.StandardOutput.ReadToEnd(); // debugger does not move past this line
p.Close();
.exe は単純な http 要求アプリであり、ローカル ファイルなどにはアクセスせず、結果をコンソールに出力します。
これは最初はパーミッションの問題かもしれないと思っていたので、デバッグ目的でFetchIntranetPageSpecial.exeパーミッションを「EVERYONE, EVERYTHING」に設定してください。
次に何を試すことができるかについての指針はありますか?
EDIT : このページProgram does not terminate when using processesも読みましたが、その場合、デバッガーは次の行で無期限の「待機」状態になります。
while (read.Peek() >= 0) // stuck on this line
Console.WriteLine(read.ReadLine());