0

I've encountered an unexpected problem with an .exe I use for my inter-process communication.

It seems to work in desktop directory but it fails and gives a weird unset in its code exitcode in my project directory.

enter image description here

I can't find the source of the problem. The exec is compiled to one file with all its libraries included and as you can see it works in the desktop directory but it stops in others. The same weird exitcode is given in the main program when it exits

        var process = new Process
        {
            StartInfo = {
                FileName = @"WF_Mag.exe",
                Arguments =
                    $"\"{Account.Host}\" \"{Account.DbName}\" \"No\" \"{Account.Login}\" \"{Account.Password}\" \"{Account.DateFrom.ToString("yyyy-MM-dd")}\" \"{Account.DateTo.ToString("yyyy-MM-dd")}\" ",
            CreateNoWindow = false,
            UseShellExecute = false,
            RedirectStandardError = true,
            RedirectStandardOutput = true,
            },
            EnableRaisingEvents = true
        };
        process.OutputDataReceived += Process_OutputDataReceived;
        process.Exited += (sender, args) =>
        {
            var proc = sender as Process;
            if (proc != null)
            {
                var sb = new StringBuilder();
                var exitCodeFlags = (ExitCodes)proc.ExitCode; // returns -532462766

                if (exitCodeFlags.HasFlag(ExitCodes.ArgumentsError))
                    sb.Append("Błędna liczba argumentow \n");
                if (exitCodeFlags.HasFlag(ExitCodes.DateFromError))
                    sb.Append("Zły format daty początkowej \n");
                if (exitCodeFlags.HasFlag(ExitCodes.DateToError))
                    sb.Append("Zły format daty końcowej \n");
                if (exitCodeFlags.HasFlag(ExitCodes.LibraryError))
                    sb.Append("Błąd wewnętrzny biblotek \n");
                if (exitCodeFlags.HasFlag(ExitCodes.WrongConnectionData))
                    sb.Append("Złe dane połączenia \n");

                ip.Report(exitCodeFlags == ExitCodes.Success
                    ? new Tuple<string, int?, bool>("Proces pobierania zakończył sie sukcesem", 100, false)
                    : new Tuple<string, int?, bool>("Proces pobierania zakończył sie błędnie \n" + sb, 100, true));
            }
        };

        process.Start();
        process.BeginOutputReadLine();
        process.WaitForExit();

I'm stuck and I'm looking for some ideas what can cause the problem. I'd be very thankful for any suggestions.

Thanks in advance

SebOlens
  • 519
  • 3
  • 15
  • From the screenshots, it seems clear that the problem is somewhere inside `WF_Mag.exe`, not anywhere in the code you've posted. The error code (converted to hexadecimal) is 0xE0434352, so see, e.g., http://stackoverflow.com/q/6244939/886887 – Harry Johnston Aug 17 '16 at 23:25
  • Ok i found the problem. In the directory of my project there was a dll named the same as the dll used in the .exe... It works fine when I added an extra folder – SebOlens Aug 18 '16 at 09:51

0 Answers0