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