"only part of a readprocessmemory or writeprocessmemory request was completed" during process.start [duplicate]

StackOverflow https://stackoverflow.com/questions/13612212

  •  03-12-2021
  •  | 
  •  

Вопрос

Possible Duplicate:
C# Only part of a ReadProcessMemory or WriteProcessMemory request was completed during Process.Kill()

I'm trying to kick off a new process from my current process. I'm using processInfo and process.start to do this. The new process is supposed to run an exe I've built previously, call it newProc.exe, which runs fine from the cmd line.

Code for the calling exe

class Program
    {
        static void Main(string[] args)
        {
            StartNewProc();
        }

        public static void StartNewProc()
        {
            string pathToNewProc = @"c:\path\to\newproc.exe";

            ProcessStartInfo processInfo = new ProcessStartInfo();
            processInfo.FileName = pathToNewProc;
            processInfo.Arguments = "Some cmd line argument";
            processInfo.CreateNoWindow = false;
            processInfo.WindowStyle = ProcessWindowStyle.Hidden;

            Process proc = Process.Start(processInfo);
            proc.WaitForExit();
        }
    }

When I run this, either in the visual studio debugger or from the cmd line, the newProc.exe doesn't get launched. Looking at it in the debugger, if I look at 'proc' after Process.Start, I can see an exception thrown in the MainModule member. The exception message is "Only part of a ReadProcessMemory or WriteProcessMemory request was completed".

Looking deeper into that exception's stackTrace

System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly) at System.Diagnostics.Process.get_MainModule()

Some research into that exception points at 32bit vs 64 bit issues. Both exes, the newProc exe and the calling exe whose code I've posed, are 64 bit apps. I checked via the application properties and via Task Manager (looking for the "*32" tag). I've tried setting the platform to both x64 and Any CPU in visual studio but no luck.

Any ideas on why Process.Start would fail to read in these conditions?

Notes: This is on Win7 64bit. Both exes are C# applications. Both are using the 2.0 framework (old i know but necessary).

Это было полезно?

Решение

I figured it out. The problem was entirely in my newProc application. It was exiting early because of a args.Len check. The exception that was returned was just misleading and took me on a bit of a wild goose chase.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top