Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Help on "GetProcessesByName(String processName)"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
langhera@egaspari.net - 13 Mar 2006 16:47 GMT
I use this to know if a program is running; until now all ok but on a pc the
procedure return this error :

System.InvalidOperationException: Impossibile ottenere informazioni sui
processi dal computer remoto. ---> System.ArgumentOutOfRangeException: I
segni di graduazione devono essere compresi tra DateTime.MinValue.Ticks e
DateTime.MaxValue.Ticks.
Nome parametro: ticks
  at System.DateTime..ctor(Int64 ticks)
  at System.DateTime.Subtract(TimeSpan value)
  at System.Diagnostics.NtProcessManager.GetThreadInfo(PERF_OBJECT_TYPE
type, IntPtr instancePtr, PERF_COUNTER_DEFINITION[] counters)
  at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library, Int32 processIndex, Int32 threadIndex, IntPtr dataBlockPtr)
  at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
  --- Fine dell'analisi dello stack dell'eccezione interna ---
  at
System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib
library)
  at System.Diagnostics.NtProcessManager.GetProcessInfos(String
machineName, Boolean isRemoteMachine)
  at System.Diagnostics.ProcessManager.GetProcessInfos(String machineName)
  at System.Diagnostics.Process.GetProcessesByName(String processName,
String machineName)
  at System.Diagnostics.Process.GetProcessesByName(String processName)
  at GModDoc.Connect.InizializzaMonitor()

Does any one know why?
Thank's for help
Michael D. Ober - 14 Mar 2006 15:11 GMT

Please post your code.

Mike Ober.

> I use this to know if a program is running; until now all ok but on a pc the
> procedure return this error :
[quoted text clipped - 28 lines]
> Does any one know why?
> Thank's for help
langhera@egaspari.net - 15 Mar 2006 10:24 GMT
The code is :

   Private Sub InizializzaMonitor()
       '
       '   Verifica se monitor già istanziato
       '
       Try
           Dim localAll As Process() = Process.GetProcessesByName("wrdMon")
           If localAll.Length = 0 Then
               Dim strLocation As System.String =
System.Reflection.Assembly.GetExecutingAssembly.Location.Substring(0,
System.Reflection.Assembly.GetExecutingAssembly.Location.LastIndexOf("\"))
               Process.Start(strLocation & "\wrdMon.exe")
           End If
       Catch ex As Exception
           Err(ex, "InizializzaMonitor - Server Applicazione")
       End Try

       '
       '   Carica riferimento a dll Server dati
       '
       Try
           aMon =
CType(Activator.GetObject(GetType(Gaspari.srvAddIn.AppMonitor),
"tcp://localhost:8888/appMonitor"), Gaspari.srvAddIn.AppMonitor)
           'aMon = New Gaspari.srvAddIn.AppMonitor
           '
           '   Se utente loggato abilita comandi gaspari
           '
           DistruggiVarsToolbar()
           If aMon.usrLog Then
               SetToolBar(tlbMain, "0111111111")

               CreaVarsToolbar()

               tlbMain.Position = MsoBarPosition.msoBarTop
               tlbMain.Visible = True

               applicationObject.ScreenRefresh()
           End If
       Catch ex As Exception
           Err(ex, "InizializzaMonitor - Caricamento Dll")
       End Try

   End Sub

The error is in the line " Dim localAll As Process() =
Process.GetProcessesByName("wrdMon")"

The client has win2K (Sp.??)
Thank for help
Michael D. Ober - 15 Mar 2006 15:04 GMT

Try the following

Dim wrdMon as Process = Nothing
for each p as process in process.GetProcesses()
 if p.Name = "wrdMon" then
    wrdMon = p
    exit for
 end if
next p

if wrdMon is Nothing then
  Dim strLocation As System.String =
 System.Reflection.Assembly.GetExecutingAssembly.Location.Substring(0,
System.Reflection.Assembly.GetExecutingAssembly.Location.LastIndexOf("\"))
                 Process.Start(strLocation & "\wrdMon.exe")
            End If

I have had similar problems with GetProcessesByName either failing or simply
not finding the process even when I know it's running.

Mike.

> The code is :
>
[quoted text clipped - 47 lines]
> The client has win2K (Sp.??)
> Thank for help

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.