Browse Source

improve error message if accessing the performance counters fails

pull/27/head
Siegfried Pammer 14 years ago
parent
commit
58bcbca3a7
  1. 13
      src/AddIns/Analysis/Profiler/Controller/Profiler.cs

13
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 (usePerformanceCounters) {
if (performanceCounterInstanceName == null) if (performanceCounterInstanceName == null)
performanceCounterInstanceName = PerformanceCounterDescriptor.GetProcessInstanceName(profilee.Id); performanceCounterInstanceName = PerformanceCounterDescriptor.GetProcessInstanceName(profilee.Id);
if (performanceCounterInstanceName == null) if (performanceCounterInstanceName == null) {
LogString("instance not found!"); 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