We have a legacy VB6 application that runs a separate C# EXE. The VB6 application relies on the C# application to perform a particular task. When the task is done successfully it will return with exit code 0, or 1 if failure.
This works well on our development machines (yes, we tried on more than 1 machine). But, when we tried it on the client machine it always returns a 0 exit code no matter the result of the task.
The really strange part is that this scenario has been working perfectly for about 8 months until this first happenned.
We even tried to make a simple C# 'runner app' that only calls an exe and catches its exit code. Again, it worked fine on our development machine but always return 0 on the client machine. So, we concluded that the problem is not in the VB6 program.
This is the C# 'runner app' code snippet that call the .exe program:
System.Diagnostics.Process installProcess = new System.Diagnostics.Process();
installProcess.StartInfo.FileName = this.textBox1.Text;
installProcess.StartInfo.Arguments = this.textBox2.Text;
installProcess.Start();
installProcess.WaitForExit();
MessageBox.Show("Exit code : " + installProcess.ExitCode.ToString());
And this is the C# code snippet that exit the program with custom exit code:
Environment.Exit(1);
Well, we suspect there's some configuration on the client machine OS that causes this strange behavior on the client machine.