Home All Groups Group Topic Archive Search About

Exception occurs when getting ProcessName

Author
17 Apr 2006 8:38 PM
Patriot
I am having this error quite often, but not every time.
I have looked around some of these forums and don't seem to find any
post with the similar problem. Could someone point out what could be
the problem?

Dim myProcesses() As Diagnostics.Process
Dim myProcess As Diagnostics.Process
Dim sProcName As String

myProcesses = Diagnostics.Process.GetProcesses

For Each myProcess In myProcesses
       With myProcess
               sProcName = .ProcessName       'Exception here.
               console.writeline(sProcName)
       End With
Next



System.ComponentModel.Win32Exception: Unable to enumerate the process
modules.
at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId)
at System.Diagnostics.Process.get_Modules()
at System.Diagnostics.Process.get_MainModule()
at System.Diagnostics.Process.get_ProcessName()
at Process_Controller.ProcessKiller.Main() in C:\My
Projects\VB.Net\WindowsUtils\Process Killer\ProcessKiller.vb:line 41

Author
17 Apr 2006 9:04 PM
Kevin Spencer
It is possible that processes are being started and/or stopped during
execution.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

Show quote
"Patriot" <tim.***@gmail.com> wrote in message
news:1145306326.673470.108610@v46g2000cwv.googlegroups.com...
>I am having this error quite often, but not every time.
> I have looked around some of these forums and don't seem to find any
> post with the similar problem. Could someone point out what could be
> the problem?
>
> Dim myProcesses() As Diagnostics.Process
> Dim myProcess As Diagnostics.Process
> Dim sProcName As String
>
> myProcesses = Diagnostics.Process.GetProcesses
>
> For Each myProcess In myProcesses
>       With myProcess
>               sProcName = .ProcessName       'Exception here.
>               console.writeline(sProcName)
>       End With
> Next
>
>
>
> System.ComponentModel.Win32Exception: Unable to enumerate the process
> modules.
> at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId)
> at System.Diagnostics.Process.get_Modules()
> at System.Diagnostics.Process.get_MainModule()
> at System.Diagnostics.Process.get_ProcessName()
> at Process_Controller.ProcessKiller.Main() in C:\My
> Projects\VB.Net\WindowsUtils\Process Killer\ProcessKiller.vb:line 41
>

AddThis Social Bookmark Button