diff --git a/src/AddIns/Analysis/Profiler/Controller/Profiler.cs b/src/AddIns/Analysis/Profiler/Controller/Profiler.cs index 138cf1aad2..253764d6b1 100644 --- a/src/AddIns/Analysis/Profiler/Controller/Profiler.cs +++ b/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) { using (DataSet dataSet = new DataSet(this, ptr + offset, length, nativeStartPosition, nativeRootFuncInfoPosition, isFirst, is64Bit)) { lock (this.dataWriter) { this.dataWriter.WriteDataSet(dataSet); - if (performanceCounterInstanceName == null) - performanceCounterInstanceName = PerformanceCounterDescriptor.GetProcessInstanceName(profilee.Id); - - if (performanceCounterInstanceName == null) - LogString("instance not found!"); + if (usePerformanceCounters) { + if (performanceCounterInstanceName == null) + performanceCounterInstanceName = PerformanceCounterDescriptor.GetProcessInstanceName(profilee.Id); + + 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) counter.Collect(performanceCounterInstanceName);