Catch another process unhandled exception?

If you are calling to a . Net executable assembly you can load it and (at your own risk :D ) call to the Main method of the Program class into a try_catch statement.

If you are calling to a . Net executable assembly you can load it and (at your own risk :D ) call to the Main method of the Program class into a try_catch statement: Assembly assembly = Assembly. LoadFrom("ErroneusApp.

Exe"); Type types= assembly.GetTypes(); foreach (Type t in types) { MethodInfo method = t. GetMethod("Main", BindingFlags. Static | BindingFlags.

NonPublic); if (method! = null) { try { method. Invoke(null, null); } catch (Exception ex) { Console.

WriteLine(ex. Message); } break; } } But be aware of the security risks you are introducing doing that.

I think this is the exact answer I'm currently looking for Thank you very sir. P.S. In my implementation, I think im going to add the newly loaded assembly to a new AppDomain. – Ahmad Hajou Feb 18 '10 at 16:12 I gotta ask here, is there a way to find out if the exe is a .

Net executable assembly? What if the application is under . Net 2.0 while the other is 3.5, will that matter?

– Ahmad Hajou Feb 18 '10 at 16:14.

No. If the controlled app utilizes standardError and return codes you may be notified of the occurance of an error or exception but you cannot trap it in any way.

1 for not trying to hedge anything. – Al W Feb 17 '10 at 8:27.

You can try something like that to avoid the debugger question to appear, you won't get the exception but only the exit code: class Program { static void Main(string args) { try { ProcessStartInfo info = new ProcessStartInfo("ErroneusApp. Exe"); info. ErrorDialog = false; info.

RedirectStandardError = true; info. RedirectStandardOutput = true; info. CreateNoWindow = true; info.

UseShellExecute = false; System.Diagnostics. Process p = System.Diagnostics.Process. Start(info); p.

EnableRaisingEvents = true; p. Exited += p_Exited; } catch (Exception ex) { Console. WriteLine(ex.

Message); } Console.ReadLine(); } static void p_Exited(object sender, EventArgs e) { Process p = sender as Process; if (p! = null) { Console. WriteLine("Exited with code:{0} ", p.

ExitCode); } else Console. WriteLine("exited"); } } In this question they provided another workaround for that, but changing some registry values.

I don't think this is what I am looking for 10x for the help anyway – Ahmad Hajou Feb 17 '10 at 10:36.

Instead of doing the whole sneaking around the assembly to try to find the Main method like in jmservera's answer, you can simply execute the assembly in a new domain. See this msdn article.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions