T
Tomasz Jastrzebski
Hello All,
I experience a strange problem I do not how to approach.
My windows service application uses several performance counter.
Before when staring the service deletes category and attempts to recreate
it.
*If* the category previously existed and has been deleted prior to
recreation an attempt to create a counter causes Service Manager timeout
after 30 sec. So, category gets deleted, but it can not be recreated.
I modified my service so it deletes category upon termination, but then it
fails during the restart while checking if the category exists.
It is completely weird.
Now, the really strange part: the same code executed as a console
application with *the same security credentials* executes momentarily.
Sample code attached below. The code uses .Net 2.0 methods but the same
issue can be seen in .Net 1.1.
Did anyone experience a similar issue? Is there any known solution?
Thank you,
Tomasz
Const ThisServiceName As String = "My Service"
Trace.WriteLine("Checking performance counters category.")
If PerformanceCounterCategory.Exists(ThisServiceName) Then
Trace.WriteLine("Deleting performance counters.")
PerformanceCounterCategory.Delete(ThisServiceName)
Trace.WriteLine("Performance counters deleted.")
End If
WriteToLog("Creating performance counters.")
PerformanceCounterCategory.Create(ThisServiceName, "",
PerformanceCounterCategoryType.MultiInstance, "test counter", "")
WriteToLog("Performance counters created.")
I experience a strange problem I do not how to approach.
My windows service application uses several performance counter.
Before when staring the service deletes category and attempts to recreate
it.
*If* the category previously existed and has been deleted prior to
recreation an attempt to create a counter causes Service Manager timeout
after 30 sec. So, category gets deleted, but it can not be recreated.
I modified my service so it deletes category upon termination, but then it
fails during the restart while checking if the category exists.
It is completely weird.
Now, the really strange part: the same code executed as a console
application with *the same security credentials* executes momentarily.
Sample code attached below. The code uses .Net 2.0 methods but the same
issue can be seen in .Net 1.1.
Did anyone experience a similar issue? Is there any known solution?
Thank you,
Tomasz
Const ThisServiceName As String = "My Service"
Trace.WriteLine("Checking performance counters category.")
If PerformanceCounterCategory.Exists(ThisServiceName) Then
Trace.WriteLine("Deleting performance counters.")
PerformanceCounterCategory.Delete(ThisServiceName)
Trace.WriteLine("Performance counters deleted.")
End If
WriteToLog("Creating performance counters.")
PerformanceCounterCategory.Create(ThisServiceName, "",
PerformanceCounterCategoryType.MultiInstance, "test counter", "")
WriteToLog("Performance counters created.")