Catch ERROR in EXE file if called from C# code

后端 未结 1 1865
挽巷
挽巷 2021-01-29 09:45

I am running an exe file from C# code, due to some reasons error occurs in that exe file. It keeps waiting and ultimately gives a popup error \"abc.exe has stopped working\" and

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-29 10:10

    This link might be useful https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandarderror%28v=vs.110%29.aspx

    Subscribe to ErrorDataReceived event and get the error message. enter link description here

    Instead of waiting for it to exit, you can subscribe to Process Exit event

    If your exe is giving some kind of unhandled exception, you won't be able to get the exact error. Windows event viewer may help you in getting the error number and possible causes.

    0 讨论(0)
提交回复
热议问题