In my code i am running an exe file through a process call. How to handle exception generated by the exe file. Can someone please help.
Asked
Active
Viewed 1,446 times
1 Answers
0
If the exe file is unmanaged, you can't catch exceptions that it throws.
What you can do, is check its error code once the process exits. To do that use the Process
class to launch the exe. It has a property that gives you the exit code.
If the exe was a managed assembly, you would have been able to run it in a separate AppDomain, and catch the exception it threw.

Ran
- 5,989
- 1
- 24
- 26
-
But i am not running any assembly, it's just an exe file (lets us say executable file of a c program). – Deviprasad Das Dec 07 '10 at 07:12
-
So the process exit code is what you've got. A C program doesn't even have exceptions... – Ran Dec 07 '10 at 07:23
-
Suppose a C program has code "int a = b / 0;". So at run time it is creating an exception and showing an message box saying "Progam.exe has encountered a problem, do you want to send the report to microsoft", with "Send", "Don't send" button. – Deviprasad Das Dec 07 '10 at 07:27