简体   繁体   中英

Incorrect Exit Code returned by Process.ExitCode Property

I have a native C++ application that I am running as a process during the execution of a C++/CLI application and I am seeing some strange behaviour with the exit code. I expect the exit code to be 0 when the process exits correctly but Process.ExitCode returns -529697949. However, when I debug the C++ application I can see that the exit code being returned is actually 0. Why would the Process.ExitCode property not match this value?

The absolute most important assumption to make when a program misbehaves is to never assume it is a bug in code that's used by hundreds of thousands of programmers and runs on half a billion machines. Assume it is a problem in your program first.

Armed with that knowledge, take a better look at the number. A good strategy when the number looks large and random is always to convert it hex. -529697949 = 0xe06d7363. Shazam, magic number, googles well too. That's the value of a Windows exception code. e0 makes it a fatal error, 6d7363 are ASCII codes that spell "msc".

Your program crashed on an unhandled C++ exception.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM