Windows SDK - C # - Debugging process with error code -1073741502

SHORT VERSION

How do you know which DLL does not load (and possibly why) when the process exits with error code -1073741502?

LONG TERM

I am trying to write a pretxnchangegroup hook for Mercurial, and as part of this hook I need to get the result of the command:

hg log

The code that I use to start and run the hg.exe process is as follows:

 string Command = "log"; Process p = new Process(); ProcessStartInfo psi = p.StartInfo; p.StartInfo.FileName = @"C:\Program Files (x86)\Mercurial\hg.exe"; psi.CreateNoWindow = true; psi.LoadUserProfile = true; psi.RedirectStandardError = true; psi.RedirectStandardOutput = true; psi.UseShellExecute = false; psi.WorkingDirectory = Environment.CurrentDirectory; p.StartInfo.Arguments = Command; // Pass-through environment variables psi.UserName = Properties.Settings.Default.HG_User; psi.Domain = Properties.Settings.Default.HG_Domain; psi.Password = new System.Security.SecureString(); foreach (char c in Properties.Settings.Default.HG_Pass) { psi.Password.AppendChar(c); } p.Start(); p.WaitForExit(); 

The problem is that the process continues to exit with error code -1073741502, without outputting anything to standard output or standard error. After some research on the Internet, I found that this error code has something to do with the fact that the application cannot initialize correctly (cannot find the DLL, maybe?), But I don’t know how to find out how to fix it.

Keep in mind that this hook is called when I click on the repository over the Internet (therefore IIS calls Mercurial CGI through Python, which has this program configured as a hook).

In a completely different web application, I can just run the HG commands, and I can also run this by running runas /user:<same account as in the code> /noprofile cmd.exe , and then manually enter the hg command line.

Also, if I set UseShellExecute = true , then it runs just fine, but then I cannot get the standard output. I really feel like just making a web service call in a web application that can successfully execute this command, but that would be a very ugly solution.

Any ideas why this thing is not being implemented?

+6
c # windows mercurial process winapi
source share
2 answers

I think this may be due to the way Windows handles the new processes that you spawn.
Each process will consume non-interactive desktop memory until a bunch of windows run out and processes are no longer running.

http://www.tomshardware.co.uk/forum/217729-36-application-failed-initialize-properly-0xc0000142

http://blogs.msdn.com/b/ntdebugging/archive/2007/01/04/desktop-heap-overview.aspx

+4
source share

I was able to resolve this by disabling UAC so that it sounds like a permission issue, although I don't know the exact data.

+1
source share

All Articles