A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Thank you for reaching out.
-1073741819 is not a normal “return 0” from your program. It maps to 0xC0000005, which means the C++ process ended because of an access violation (crash). So Windows is reporting that the process crashed, and that is why your C# app sees this exit code.
From your latest update, the behavior happens only when your C++ code calls ShellExecuteEx. That is a strong sign the crash is happening in the ShellExecuteEx path, not in your normal output logic.
A key detail is that ShellExecuteEx can hand off work to Shell extensions and COM components. Microsoft notes that COM should be initialized before calling ShellExecuteEx, because some Shell extensions require it.
So, a practical suggestion is:
- Make sure COM is initialized in the thread before calling
ShellExecuteEx(some Shell extension handlers depend on it). - Check Windows Event Viewer > Application logs at the time it happens, because it usually shows the faulting module and confirms where the crash is coming from.
Also, since you are launching an executable, another safe option is to avoid Shell-based launching if you don’t need file association behavior. ShellExecuteEx is meant for “shell verbs / associations”, and it can involve extra shell components. If you only need to start an exe with arguments and wait for it, using a direct process creation approach (like CreateProcess) avoids shell extensions and can be more predictable. (This is a general recommendation based on how ShellExecuteEx works.)
References
Please let us know if you require any further assistance, we’re happy to help. If you found this information useful, kindly mark this as "Accept Answer". So that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.