im making a task manager application (server-client) .. so i get processors list from the server as a string.
my problem that 60-65% of processors count is failed to get in the server side as you see in the task manager snapshot .. note that server application debugged as administrator
Server code:
public void GetProcessors()
{
int i =0,j = 0;
string answer = "";
foreach (Process p in Process.GetProcesses())
{
try
{
answer += p.MainModule.ModuleName
+ "|" + p.Id.ToString()
+ "|" + string.Format("{0:N0} K", p.WorkingSet64 / 1024)
+ "|" + p.MainModule.FileVersionInfo.FileDescription;
i++;
answer += "?";
}
catch
{
j++;
}
}
answer = answer.Remove(answer.Length - 1, 1);
send(string.Format("get<{0}<{1}<{2}", answer, i, j));
}
Client side:
this called the getProcessors method from task manager class
switch(command[1])
{
case "get":
Console.WriteLine(command[2]);
if (InvokeRequired)
{
Action a = () => taskManager1.GetProcessors(command[2], command[3], command[4]);
Invoke(a);
}
break;
default:
break;
}
(client side) TASK MANAGER CLASS :
public void GetProcessors(string cmd,string success,string fail)
{
string[] Processors = cmd.Split('?');
foreach (string process in Processors)
{
string[] info = process.Split('|');
if (info.Length < 4)
{
MessageBox.Show(info.Length.ToString());
continue;
}
ListViewItem item = new ListViewItem(info[0]);
item.SubItems.Add(info[1]);
item.SubItems.Add(info[2]);
item.SubItems.Add(info[3]);
listView1.Items.Add(item);
}
labelProcess.Text = string.Format("Processors: {0}", success);
failedLabel.Text = string.Format("Failed: {0}", fail);
}

i got those exception
85 FAILS : 83 are {“A 32 bit processes cannot access modules of a 64 bit process.”}
the other 2 FAILS : {“Unable to enumerate the process modules.”}
after i edited the code and tried to run it without using Process.MainModule .. it gives me:
process : 147 .. FAIL : 0 .. so why i can’t access to process.MainModule ?
After i changed my application debugger to x64 it works .. but i think now i have to make two copies 32bit and 64bit
…