I am using VB.net on a win xp box. I keep getting an
InvalidOperationException when checking CounterExists
Method on the Performance category. I am trying to use
the get PerformanceCounterCategory.CounterExists and it
fails every time.
here is the code
Dim PerfCategory As New
PerformanceCounterCategory(ApplicationName) '**TRIED
SETTING NAME HERE
Dim PerfCounter As PerformanceCounter
Try
' Check to see if the category exists
If PerfCategory.Exists(ApplicationName)
Then
' ** TRIED SETTING HERE Set the
category Name
PerfCategory.CategoryName =
ApplicationName
Try
' Check to see if the counter
exists if not the create category
'** IT HAS THE CATEGORY NAME BUT THIS STILL FAILS WHY????
If PerfCategory.CounterExists
(PerfCounterName) Then
Return True
Else
Return False
End If
Catch ex As
System.InvalidOperationException
' Need to remove and add a new
category
If ex.Message = "Category does
not exist." Then
Return True
End If
End Try
End If
Catch ex As Exception
thanks in advance
-R