I am getting an error with the following code:
var p = new Process();
p.EnableRaisingEvents = true;
p.StartInfo.FileName = this.CommandLine;
p.StartInfo.Arguments = this.CommandArgs;
p.Exited += new EventHandler(OnProgramExit);
p.Start();
When this code is executed, shortly after the process is started, i get an error within the Framework: NullReferenceException at System.Diagnostics.Process.TermWaiter.WaitForTerm().
If i remove the line "p.EnableRaisingEvents = true", the code executes without a problem, but the Exited event is never fired. If i handle the code synchronously with "p.WaitForExit();" the code works fine, however the program hangs waiting for the process to exit.
Any ideas? It's probably worth emphasizing that this is in the Compact Framework (v 3.5). In my tests i am just running the calculator (\Windows\calc.exe) on a device running CE 5.0.