Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7589059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:04:25+00:00 2026-05-30T20:04:25+00:00

I started a new project listing the full paths to all running processes. When

  • 0

I started a new project listing the full paths to all running processes. When accessing some of the processes the program crashes and throws a Win32Exception. The description says an error occured while listing the process modules. Initially I thought this problem might occur because I’m running it on a 64-bit platform, so I recompiled it for the CPU types x86 and AnyCPU. I’m getting the same error, though.

Process p = Process.GetProcessById(2011);
string s = proc_by_id.MainModule.FileName;

The error occurs in line #2. The blank fields show processes where the error occured:
Screenshot

Is there any way to get around this error message?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:04:26+00:00Added an answer on May 30, 2026 at 8:04 pm

    The exception is thrown when you try to access the MainModule property. The documentation for this property does not list Win32Exception as a possible exception, but looking at the IL for the property it is evident that accessing it may throw this exception. In general it will throw this exception if you are trying to do something that is impossible or not allowed in the OS.

    Win32Exception has the property NativeErrorCode and also a Message that will explain what the problem is. You should use that information to troubleshoot your problem. NativeErrorCode is the Win32 error code. We can guess all day long what the problem is but the only way to actually figure this out is to inspect the error code.

    But to continue guessing, one source of these exceptions is accessing 64 bit processes from a 32 bit process. Doing that will throw a Win32Exception with the following message:

    A 32 bit processes cannot access modules of a 64 bit process.

    You can get the number of bits of your process by evaluating Environment.Is64BitProcess.

    Even running as a 64 bit process you will never be allowed to access MainModule of process 4 (System) or process 0 (System Idle Process). This will throw a Win32Exception with the message:

    Unable to enumerate the process modules.

    If you problem is that you want to make a process listing similar to the one in Task Manager you will have to handle process 0 and 4 in a special way and give them specific names (just as Task Manager does). Note that on older versions of Windows the system process has ID 8.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi all I've just started a new project using Visual Web Developer 2008 Express
I started a new WPF project in VS2008 and then added some code to
I've recently started a new project in C#, and, as I was coding some
I started to implement some new html5 features (standards, nothing fancy) in my project.
So I started this new project, and I was trying to incorporate all the
I just started a new project running Xcode 4.2.1 and iOS5 SDK. The project
We started a new project and the nature of the project is very interactive
I have just started a new project, and I am using the Delphi 2009
I started doing a new project in PHP / MySql . The Aim of
I recently started a new webforms project and decided to separate the business classes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.