开发者

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

开发者 https://www.devze.com 2023-02-18 18:01 出处:网络
SHORT VERSION How do you figure out which DLL is failing to load (and potentially why) when a process exits with error code -1073741502?

SHORT VERSION

How do you figure out which DLL is failing to load (and potentially why) when a process exits with error code -1073741502?

LONG VERSION

I'm trying to write a pretxnchangegroup hook for Mercurial, and as a part of that hook I need to get the output of running the command:

hg log

The code that I'm using 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 keeps exiting with error code -1073741502, without outputting anything on Standard Output or Standard Error. After some research online, I discovered that this error code has something to do with the application failing to initialize properly (couldn't find DLL's, maybe?), but I have no idea how to go about figuring out how to fix it.

Keep in mind that this hook is being called for when I'm pushing to the repository over the web (so, IIS is calling the Mercurial CGI via Python, which has this program configured as a hook).

In 开发者_StackOverflowa totally different web application, I'm able to run HG commands just fine, and I'm also able to run this by doing runas /user:<same account as in the code> /noprofile cmd.exe and then manually typing in the hg command line.

Also, if I set UseShellExecute = true, then it executes just fine, but then I can't get the Standard Output. I'm really tempted to just make a web service call to the web app which is able to execute this command successfully, but that'd be a really ugly solution.

Any ideas why this thing isn't executing?


I was able to resolve this by disabling UAC so it sounds like a permissions problem even though I do not know the exact details.

0

精彩评论

暂无评论...
验证码 换一张
取 消