Process.Kill() online problem
i am getting process's information in web application its working fine at local (my machine) but when i doploy it i face exception on function calling Quitter(ProcId) here is my code
Dim ProcId As Integer = 0
Dim Process1() As Process = Process.GetProcesses()
Dim xApp As New Excel.Application
Dim Process2() As Process = Process.GetProcesses()
Dim i, j As Integer
Dim bMonProcessXL As Boolean
For j = 0 To Process2.GetUpperBound(0)
If Process2(j).ProcessName = "EXCEL" Then
bMonProcessXL = True
' Parcours des processus avant le mien
For i = 0 To Process1.GetUpperBound(0)
If Process1(i).ProcessName = "EXCEL" Then
If Process2(j).Id = Process1(i).Id Then
' S'il existait avant, ce n'était pas le mien
bMonProcessXL = False
Exit For
End If
End If
Next
If bMonProcessXL = True Then
' Maintenant que j'ai son Id, je pourrai le tuer
' xlApp.Hinstance ne fonctionne pas avec Excel 2000
' alors que cette méthode marche toujours !
ProcId = Process2(j).Id
Exit For
End If
End If
Next
Quitter(ProcId)
Public Sub Quitter(ByVal ProcId As Integer)
If ProcId = 0 Then Exit Sub
Process.GetProcessById(ProcId).Kill()
End Sub
on calling Quitter(ProcId) exception is occuring "couldn't get process information from remote machine ".this exception is occuring online. at local its working fine
Have a look on exception:
ERROR MESSAGE:-->Couldn't get process information from remote machine.
EXCEPTION.TOSTRING MESSAGE:-->System.InvalidOperationException: Couldn't get process information from remote machine. ---> System.Threading.ThreadAbortException: Thread was being aborted.
at Microsoft.Win32.UnsafeNativeMethods.RegQueryValueE x(HandleRef hKey, String lpValueName, Int32[] lpReserved, Int32[] lpType, HandleRef lpData, Int32& lpcbData)
at System.Diagnostics.PerformanceMonitor.GetData(Stri ng item)
at System.Diagnostics.PerformanceCounterLib.GetPerfor manceData(String item)
at System.Diagnostics.PerformanceCounterLib.get_Categ oryTable()
at System.Diagnostics.PerformanceCounterLib.GetPerfor manceData(String[] categories, Int32[] categoryIndexes)
at System.Diagnostics.NtProcessManager.GetProcessInfo s(PerformanceCounterLib library)
--- End of inner exception stack trace ---
at System.Diagnostics.NtProcessManager.GetProcessInfo s(PerformanceCounterLib library)
at System.Diagnostics.NtProcessManager.GetProcessInfo s(String machineName, Boolean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos( String machineName)
at System.Diagnostics.Process.GetProcesses(String machineName)
at System.Diagnostics.Process.GetProcesses()
at MysteryShoppingTechnologies.clsDataBase.uploadMSPD ata(String FilePath, Int32 MSPId)
STACK TRACE:--> at System.Diagnostics.NtProcessManager.GetProcessInfo s(PerformanceCounterLib library)
at System.Diagnostics.NtProcessManager.GetProcessInfo s(String machineName, Boolean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos( String machineName)
at System.Diagnostics.Process.GetProcesses(String machineName)
at System.Diagnostics.Process.GetProcesses()
at MysteryShoppingTechnologies.clsDataBase.uploadMSPD ata(String FilePath, Int32 MSPId)
if any one can solve this problem
thanx in advance
khizar ,lahore,pakistan
|