Browse Source

improve error message if accessing the performance counters fails

4.2
Siegfried Pammer 13 years ago committed by Daniel Grunwald
parent
commit
9046067175
  1. 19
      src/AddIns/Analysis/Profiler/Controller/Profiler.cs

19
src/AddIns/Analysis/Profiler/Controller/Profiler.cs

@ -410,17 +410,26 @@ namespace ICSharpCode.Profiler.Controller
} }
} }
bool usePerformanceCounters = true;
unsafe void AddDataset(byte *ptr, TargetProcessPointer nativeStartPosition, long offset, long length, bool isFirst, TargetProcessPointer nativeRootFuncInfoPosition) unsafe void AddDataset(byte *ptr, TargetProcessPointer nativeStartPosition, long offset, long length, bool isFirst, TargetProcessPointer nativeRootFuncInfoPosition)
{ {
using (DataSet dataSet = new DataSet(this, ptr + offset, length, nativeStartPosition, nativeRootFuncInfoPosition, isFirst, is64Bit)) { using (DataSet dataSet = new DataSet(this, ptr + offset, length, nativeStartPosition, nativeRootFuncInfoPosition, isFirst, is64Bit)) {
lock (this.dataWriter) { lock (this.dataWriter) {
this.dataWriter.WriteDataSet(dataSet); this.dataWriter.WriteDataSet(dataSet);
if (performanceCounterInstanceName == null) if (usePerformanceCounters) {
performanceCounterInstanceName = PerformanceCounterDescriptor.GetProcessInstanceName(profilee.Id); if (performanceCounterInstanceName == null)
performanceCounterInstanceName = PerformanceCounterDescriptor.GetProcessInstanceName(profilee.Id);
if (performanceCounterInstanceName == null)
LogString("instance not found!"); if (performanceCounterInstanceName == null) {
usePerformanceCounters = false;
LogString("Warning: One or more performance counters could not be accessed. " +
"Please ensure that the perfmon service is enabled and running. " +
"If the problem still persists try rebuilding the performance counters " +
"by executing \"lodctr /R\" from a command line with administrative rights.");
}
}
foreach (var counter in performanceCounters) foreach (var counter in performanceCounters)
counter.Collect(performanceCounterInstanceName); counter.Collect(performanceCounterInstanceName);

Loading…
Cancel
Save