.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Process.MainModule on x64 platform throws Win32Exception: "Only part of a ReadProcessMemory or Write

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :.NET Framework
This is a very odd issue and I think it should be a bug of .Net framework. the code is like below: class Program { static void Main(string[] args) { try { Process[] procs = Process.GetProcessesByName("abc"); if(procs == null || procs.Length < 1) return; Process proc = procs[0]; Console.WriteLine("Got it: " + proc.MainModule.ModuleName); } catch (Exception ex) { Console.WriteLine("Failed to get process: {0}", ex); } Console.Read(); } } the "abc.exe" is another program compiled with "For Any CPU", and the testing operating system is Windows 2003 x64 When the code is compiled with "x64" or "For Any CPU", it works very well. but, if I change the compiling configuration to "x86", it will throw out a Win32Exception "Only part of a ReadProcessMemory or WriteProcessMemory request was completed" stack trace:    at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly)    at System.Diagnostics.NtProcessManager.GetFirstModuleInfo(Int32 processId)    at System.Diagnostics.Process.get_MainModule()    at KillProcessTest.Program.Main(String[] args) in D:\Users\rsp\KillProcessTest\KillProcessTest\Program.cs:line 18

View Complete Post

More Related Resource Links

Process.Start & Win32Exception


Hi together,

I'm currently facing a very strange problem. I would like to open the Sticky Notes program of Windows 7 (x64), which should be the easiest thing in the world:


This throws a Win32Exception (The system cannot find the file specified, Native Error 2). I tried the fully qualified path (C:\Windows\System32\StikyNot.exe), which didn't work either. Well ... if I copy the path string out of the watch of my debugger, I'm able to run the application via the run dialog.

So I added a batch file which should call the application for me:

start C:\System32\StikyNot.exe

If I run this batch via the explorer, the application pops up correctly. If I start this batch file from my application (which is in the same folder), I'll get an error (Windows cannot find ...).

I can call the calc.exe, which is in the same folder, without any problems. The application is not started from a network share nor has it the same name like the target app (StikyNot or StickyNotes).

What the ____ is going on here?

Thanks in advance,
Andreas Nägeli

ASP.NET Architecture - ASP.NET Worker Process - HTTP Pipleline - Http Modules and Handlers

"ASP.NET is a powerful platform for building Web applications, that provides a tremendous amount of flexibility and power for building just about any kind of Web application. Most people are familiar only with the high level frameworks like WebForms and WebServices which sit at the very top level of the ASP.NET hierarchy. In this article I'll describe the lower level aspects of ASP.NET and explain how requests move from Web Server to the ASP.NET runtime and then through the ASP.NET Http Pipeline to process requests.

userprincipal.changepassword throws exception


Hi all,

      userprincipal.changepassword(oldpassword, newpassword);

gives error: that is Configuration information could not be read from the domain controller, either because the machine is unavailable, or access has been denied. (Exception from HRESULT: 0x80070547)

but userDirectoryEntry.invoke("ChangePassword", new object[] { oldpassword, newpassword });

      userDirectoryEntry.CommitChanges works fine.

Any one please tell me the reason behind this.

For Multi-Language website which process is better in asp.net


 I want to build multi-language website in asp.net 2008 and asp.net 2010. So, which process is better for building application? Using either Local and Global Resource or New Folder to make separate according to language?


Application performance should be good and also easy manageable.


Please suggest me in which way I will build the application either using resource or folder. If there is any other better solution then please share.

WebControls.TableRow throws exception on Add()


I have the following method to strip hidden and user-specified columns from a gridviewrow and return a tablerow. 

    Private Shared Function StripHiddenColumns(ByVal gvRow As GridViewRow, ByVal ColumnsToExclude() As Integer) As TableRow

        Dim row As New TableRow
        Dim i As Integer = 0
            For Each cell As TableCell In gvRow.Cells
                If cell.Visible Then
                    If Not ColumnsToExclude.Contains(i) Then
                    End If
                End If
                i += 1

            Return row
        Catch ex As Exception
            Throw ex
        End Try
    End Function

However, when I run this code and hit the Add method for the TableRow,  I get an InvalidOperationException stating the Collection was modified; enumeration operation may not execute.  I've gotten this exception before, but usually it's because I'm attempting to modify a table that is databound.  This particular one is not, i am creating it.  Can anyone offer any insight? 

Thanks in advance.


Cloud Computing: Windows Azure Platform for Enterprises


Learn all about Microsoft's Windows Azure platform at the architectural level and how it addresses enterprise cloud computing concerns including economics, security, storage and more. Included are an Azure pricing table and a sample cost calculator.

Hanu Kommalapati

MSDN Magazine February 2010

CLR Inside Out: In-Process Side-by-Side


The new .NET Framework 4.0 maintains backward compatibility while allowing core innovations by using a new feature called In-Process Side-by-Side. Learn about how it works and some problems it didn't solve.

Luiz Fernando Santos, Jesse Kaplan

MSDN Magazine December 2009

SQL Data Services: The Relational Database of the Azure Services Platform


This article shows you the new face of SQL Data Services, explores its architecture, and shows how it is truly an extension of SQL Server in the cloud.

David Robinson

MSDN Magazine August 2009

"Oslo" Basics: Build Metadata-Based Applications With The "Oslo" Platform


We introduce you to "Oslo" and demonstrate how MSchema and MGraph enable you to build metadata-driven apps. We'll define types and values in "M" and deploy them to the repository.

Chris Sells

MSDN Magazine February 2009

Team System: Streamline Team Projects With Process Templates


See how you can streamline your team projects using Process Templates in Visual Studio Team System (VSTS)

Brian A. Randell

MSDN Magazine December 2008

Security Briefs: Threat Models Improve Your Security Process


Using threat models to drive your security engineering process helps prioritize the code review, fuzz testing, and attack surface analysis tasks.

Michael Howard

MSDN Magazine November 2008

Security Briefs: Reinvigorate your Threat Modeling Process


In this column the author outlines some approaches to threat modeling that can be employed by development teams of any size.

Adam Shostack

MSDN Magazine July 2008

CI Server: Redefine Your Build Process with Continuous Integration


Jay Flowers demonstrates how to set up and use a Continuous Integration server using both discrete tools and the more comprehensive CI Factory solution.

Jay Flowers

MSDN Magazine March 2008

Toolbox: Automated Build Process, Real-World E-Mail Tasks, and More


While the Visual Studio® Build menu's Build Solution option is the usual way developers compile their current work on a project, the process of building the complete solution for testing, deployment, or production often requires many more steps.

Scott Mitchell

MSDN Magazine March 2006

Test Run: The Analytic Hierarchy Process


Most software testing takes place at a relatively low level. Testing an application's individual methods for functional correctness is one example. However, some important testing must take place at a very high level-for example, determining if a current build is significantly better overall than a previous build.

James McCaffrey

MSDN Magazine June 2005

Around the Horn: Engineer a Distributed System Using .NET Remoting for Process Intensive Analysis


Before the Microsoft .NET Framework, creating a distributed cluster of computers to perform scientific analysis was expensive in terms of hardware, programming and debugging time, and maintenance. You had to purchase expensive servers, spend time debugging network communication, design a distributed system completely different from a system deployed locally, and maintain a melting pot of error handling, data acquisition, networking, and analysis code. In this article, the author shows you how he was able to engineer a distributed computing system in C# to perform analysis of real-world data continuously acquired at high sampling rates, thanks to the .NET Framework.

Nate D'Anna

MSDN Magazine May 2005

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend