mbUnit Errors Caused by Performance Counters

I suddenly started getting the below exception with mbUnit today and I after a couple hours found out how to get rid of it. It appears The problem is related to how the Process class works in v1.1 of .NET. Apparently the Process class has a dependency on performance counters, and some how they mysteriously got disabled on my machine causing the process class to throw exceptions, and mbUnit to fail :S I resolved the problem by setting The "Disable Performance Counters" value to 0 under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance key in the registry. The .reg file you can create and double click on to fix this problem looks like this:
Windows Registry Editor Version 5.00

"Disable Performance Counters"=dword:00000000

Below is the full exception and some info I found in the debugger that actually led me to the solution. What a mess. I strongly encourage the mbUnit author to recover from such an exception or at least point out some assistance this was a nasty problem to deal with.

Command: C:\Program Files\mbUnit\mbunit.cons
Command Args: C:\Projects\blah\Source\target\blah.blah.Data.dll
Working Directory:
Assemblies: blah.blah.Data
Coverage File: C:\Projects\blah\Source\target\ncoverreport.blah.data.xml
Coverage Log:

******************* Program Output *******************
MbUnit 2.19.1666.22428 Console Application
Author: Jonathan de Halleux
Get the latest at http://mbunit.tigris.org
    /report-folder:             short form /rf  Target output folder for
 the reports
    /report-name-format:        short form /rnf Format string for the re
port name. {0} is replaced by the date, {1} by the time.Default = mbunit-{0}{1}
    /report-type:{Xml|Html|Text|Dox}    short form /rt  Report types supported:
Xml, Html, Text
    /show-reports[+|-]                  short form /sr  Show generated reports i
n a window
    /filter-category:           short form /fc  Name of the filtered cat
    /filter-author:             short form /fa  Name of the filtered aut
hor name
    /filter-type:               short form /ft  Name of the filtered typ
    /filter-namespace:          short form /fn  Name of the filtered nam
    /verbose[+|-]                       short form /v   Return a lot of informat
ion or not...
    @                             Read response file for more options
Parsed arguments:
-- Parsed Arguments
Report folder:
Report Name Format: mbunit-{0}{1}
Report types:
Show reports: False
Filter Category:
Filter Author:
Filter Namespace:
Filter Type:
Verbose: False

[loading] Assembly C:\Projects\blah\Source\target\blah.blah.Data.d
System.Exception: Problem while loading assembly ---> MbUnit.Core.Exceptions.Rep
ortExceptionException: Error in the application.

Server stack trace:

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
   at MbUnit.Core.Remoting.RemoteTestTree.Populate()
   at MbUnit.Core.Remoting.TestDomain.Load()
   --- End of inner exception stack trace ---
   at MbUnit.Core.Remoting.TestDomain.Load()
   at MbUnit.Core.Cons.MainClass.RunAssembly(ReportResult result, String aName)
[info] MbUnit execution finished in 0.160682533462706s.
***************** End Program Output *****************

	A first chance exception of type 'System.InvalidOperationException' occurred in system.dll
	Additional information: Process performance counter is disabled, so the requested operation cannot be performed.
		>	system.dll!System.Diagnostics.NtProcessManager.GetProcessInfos(System.Diagnostics.PerformanceCounterLib library = {System.Diagnostics.PerformanceCounterLib}) + 0x1c9 bytes	
		system.dll!System.Diagnostics.NtProcessManager.GetProcessInfos(string machineName = ".", bool isRemoteMachine = false) + 0xb8 bytes	
		system.dll!System.Diagnostics.ProcessManager.GetProcessInfos(string machineName = ".") + 0x34 bytes	
		system.dll!System.Diagnostics.Process.EnsureState(System.Diagnostics.Process.State state = HaveNtProcessInfo) + 0x21f bytes	
		system.dll!System.Diagnostics.Process.get_WorkingSet() + 0x14 bytes	
		mbunit.core.dll!MbUnit.Core.Monitoring.MemoryStatus.MemoryStatus(System.Diagnostics.Process p = {System.Diagnostics.Process}) + 0x47 bytes	
		mbunit.core.dll!MbUnit.Core.Monitoring.MemoryMonitor.Start() + 0x2c bytes	
		mbunit.core.dll!MbUnit.Core.RunPipeStarter.Run() + 0x15f bytes	
		mbunit.core.dll!MbUnit.Core.Remoting.RemoteTestTree.RunPipes(MbUnit.Core.Remoting.TestTreeNode node = {MbUnit.Core.Remoting.TestTreeNode}) + 0x5c bytes	
		mbunit.core.dll!MbUnit.Core.Remoting.RemoteTestTree.RunPipes(MbUnit.Core.Remoting.TestTreeNode node = {MbUnit.Core.Remoting.TestTreeNode}) + 0x93 bytes	
		mbunit.core.dll!MbUnit.Core.Remoting.RemoteTestTree.RunPipes(MbUnit.Core.Remoting.UnitTreeNode node = {System.Runtime.Remoting.Proxies.__TransparentProxy}) + 0xda bytes	
		mscorlib.dll!System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg, int methodPtr, bool fExecuteInContext) + 0x30b bytes	
		mscorlib.dll!System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg) + 0x9 bytes	
		mscorlib.dll!System.Runtime.Remoting.Messaging.ServerObjectTerminatorSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x12c bytes	
		mscorlib.dll!System.Runtime.Remoting.Messaging.ServerContextTerminatorSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x1b3 bytes	
		mscorlib.dll!System.Runtime.Remoting.Channels.CrossContextChannel.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x209 bytes	
		mscorlib.dll!System.Runtime.Remoting.Channels.ChannelServices.SyncDispatchMessage(System.Runtime.Remoting.Messaging.IMessage msg) + 0xe6 bytes	
		mscorlib.dll!System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(byte[] reqStmBuff, System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage smuggledMcm, System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage smuggledMrm) + 0x70 bytes	
		mscorlib.dll!System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatch(byte[] reqStmBuff, System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage smuggledMcm, System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage smuggledMrm) + 0x6e bytes	
		mscorlib.dll!System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x1e1 bytes	
		mscorlib.dll!System.Runtime.Remoting.Proxies.RemotingProxy.CallProcessMessage(System.Runtime.Remoting.Messaging.IMessageSink ms, System.Runtime.Remoting.Messaging.IMessage reqMsg, System.Runtime.Remoting.Contexts.ArrayWithSize proxySinks, System.Threading.Thread currentThread, System.Runtime.Remoting.Contexts.Context currentContext, bool bSkippingContextChain) + 0x62 bytes	
		mscorlib.dll!System.Runtime.Remoting.Proxies.RemotingProxy.InternalInvoke(System.Runtime.Remoting.Messaging.IMethodCallMessage reqMcmMsg, bool useDispatchMessage, int callType) + 0x28d bytes	
		mscorlib.dll!System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x113 bytes	
		mscorlib.dll!System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(System.Runtime.Remoting.Proxies.MessageData msgData, int type) + 0x288 bytes	
		mbunit.core.dll!MbUnit.Core.Remoting.TestDomainCollection.RunPipes(MbUnit.Core.Remoting.UnitTreeNode node = {MbUnit.Core.Remoting.UnitTreeNode}) + 0xad bytes	
		mbunit.forms.dll!MbUnit.Forms.ReflectorTreeView.RunTests() + 0x106 bytes

posted @ Tuesday, July 27, 2004 1:44 PM


Comments on this entry:

# re: mbUnit Errors Caused by Performance Counters

Left by Phil at 8/10/2004 9:13 PM

Thanks for posting this info. I started having the same error after using mbUnit for a while.

# Process Performance Counters problem

Left by Prabhat at 9/1/2004 2:37 AM

The solution discovered for the 'Process Performance Counter Disabled' error was by using the files
Perfc009.dat and Perfh009.dat
as mentioned in the article

The registry modification did not do much good in our case.

# re: mbUnit Errors Caused by Performance Counters

Left by overflow at 9/3/2004 1:24 AM

Thanks for the comment. Hopefully this will help others.

# re: mbUnit Errors Caused by Performance Counters

Left by Alice at 9/24/2004 12:05 AM

Thanks for posting about this.

# re: mbUnit Errors Caused by Performance Counters

Left by overflow at 9/25/2004 12:14 PM

My pleasure. Thanks for reading.

# re: mbUnit Errors Caused by Performance Counters

Left by Jamie Cansdale at 11/21/2004 11:12 AM

Have you any idea what caused the perf counters be be disabled? I'm getting the same problem now. Unfortunately the registry tweak you mentioned doesn't seem to fix it. It is anoying that even the most basic process operations don't work in when it's in this state. :(

Thanks, Jamie.

# Process Performance Disabled

Left by Test Driven .NET at 11/21/2004 2:26 PM

# re: mbUnit Errors Caused by Performance Counters

Left by Scott Willeke at 11/22/2004 1:04 PM

Unfortunately this is an elusive issue in the OS/perf counter implementation. The most information I've found related to the problem is at the link below:

Regard, scott

# re: mbUnit Errors Caused by Performance Counters

Left by Jonathan de Halleux at 7/28/2004 10:03 PM

I'm keeping a note on this...

# re: mbUnit Errors Caused by Performance Counters

Left by Jonathan de Halleux at 9/16/2004 5:15 AM


I have totally got rid of performance counters in the next version of mbUnit ( Timer is now using Ticks and memory is monitored using the workingset.

Thanks for posting about this.

# re: mbUnit Errors Caused by Performance Counters

Left by Ucha Abashidze at 7/12/2005 4:48 AM

have same problem with EGirl 1.5:

System.InvalidOperationException: Process performance counter is disabled, so the requested operation cannot be performed.
at System.Diagnostics.NtProcessManager.GetProcessInfos(PerformanceCounterLib library)
at System.Diagnostics.NtProcessManager.GetProcessInfos(String machineName, Boolean isRemoteMachine)

but your registry solution does not help (working under XP SP2)

Comments have been closed on this topic.