A process spawned through Process.Start in .NET hangs in a thread

Our application has a background thread that starts the process through System.Diagnostics.Process:

Process.Start(
    new ProcessStartInfo
    {
        FileName = url,
        UseShellExecute = true
    }
);

There was no problem at all. But now the background thread is silently dying; he never returns from a call to Process.Start. Locking this code that processes System.Exceptionis also not achieved. Even if I allow throwing exception handling in the Visual Studio debugger, I see no exceptions. Oddly enough, the process spawned just fine; The default browser for the user starts with the expected URL.

The process entry point is marked [STAThread]as recommended.

What can cause our thread to stop? Are there any methods that I can use to debug what happens when a thread completes?

Update:

It seems that the thread is alive in the end; he just doesn’t come back from the call. Here is his stack trace:

  • [Waiting for sleep or joining]
  • System.dll! System.Diagnostics.ShellExecuteHelper.ShellExecuteOnSTAThread () + 0x63 bytes
  • System.dll! System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo) + 0x19d bytes
  • System.dll! System.Diagnostics.Process.Start () + 0x39 bytes
  • System.dll! System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) + 0x32 bytes
  • My method

Update 2:

cmd.exe . ! , , .

3:

, . -, .

, , , . , cmd.exe.

+5
2

, Process.Start. Process.Start UseShellExecute, true, Windows API ShellExecuteEx , .

, , :

System.Diagnostics.Trace.WriteLine("About to start process.");
Process.Start(
   new ProcessStartInfo
   {
       FileName = url,
       UseShellExecute = true
   }
);
System.Diagnostics.Trace.WriteLine("Process started.");

TraceListener, Visual Studio , DebugView.

start. , "" URL:

Process.Start(
    new ProcessStartInfo()
    {
        FileName = "cmd.exe",
        Arguments = "/c start http://www.google.com",
        WindowStyle = ProcessWindowStyle.Hidden,
        UseShellExecute = false
    });
+4

, , . , "". Process.Start() , . - , . , - .


, ShellExecuteOnSTAThread() Thread.Join() . ShellExecuteEx() API, STA. , , STA . .

, - , - , ShellExecuteEx(). STA. Debug + Windows + Threads. "ShellExecuteFunction" . , " ", , , , . Debug + Windows + Modules " " " ".

UseShellExecute = false . , , , , .

+4

All Articles