I suddenly get some performance counter exception

Aug 26, 2013 at 12:39 AM
I rebuilt my laptop from scratch, reinstalling Windows and everything else.

I had a working prototype of a custom protocol, but now I get an exception when I start supersocket.socketservice. This used to work before the laptop rebuild.

I get the same exception when trying to start CustomProtocol in the Quick Start samples.

I tried using disablePerformanceDataCollector on the root node, and that fixed the issue.

But what if I want to use the performance counters? Currently I cannot.

Here is what is in the error log produced by SuperSocket.SocketService:

2013-08-25 19:09:15,161 [2924] ERROR DefaultBootstrap - The process crashed for an unhandled exception!
System.InvalidOperationException: Cannot load Counter Name data because an invalid index '' was read from the registry.
at System.Diagnostics.PerformanceCounterLib.GetStringTable(Boolean isHelp)
at System.Diagnostics.PerformanceCounterLib.get_NameTable()
at System.Diagnostics.PerformanceCounterLib.get_CategoryTable()
at System.Diagnostics.PerformanceCounterLib.GetCategorySample(String machine, String category)
at System.Diagnostics.PerformanceCounterCategory.GetCounterInstances(String categoryName, String machineName)
at SuperSocket.SocketEngine.PerformanceMonitor.GetPerformanceCounterInstanceName(Process process) in c:\Users\Scott\Desktop\SuperSocket(1.5.3).Source\SocketEngine\PerformanceMonitor.cs:line 64
at SuperSocket.SocketEngine.PerformanceMonitor..ctor(IRootConfig config, IEnumerable1 appServers, ILogFactory logFactory) in c:\Users\Scott\Desktop\SuperSocket(1.5.3).Source\SocketEngine\PerformanceMonitor.cs:line 44
at SuperSocket.SocketEngine.DefaultBootstrap.Initialize(Func
2 serverConfigResolver, ILogFactory logFactory) in c:\Users\Scott\Desktop\SuperSocket(1.5.3).Source\SocketEngine\DefaultBootstrap.cs:line 358
at SuperSocket.SocketEngine.DefaultBootstrap.Initialize(Func`2 serverConfigResolver) in c:\Users\Scott\Desktop\SuperSocket(1.5.3).Source\SocketEngine\DefaultBootstrap.cs:line 384
at SuperSocket.SocketEngine.DefaultBootstrap.Initialize() in c:\Users\Scott\Desktop\SuperSocket(1.5.3).Source\SocketEngine\DefaultBootstrap.cs:line 403
at SuperSocket.SocketService.Program.RunAsConsole() in c:\Users\Scott\Desktop\SuperSocket(1.5.3).Source\SocketService\Program.cs:line 84
at SuperSocket.SocketService.Program.Main(String[] args) in c:\Users\Scott\Desktop\SuperSocket(1.5.3).Source\SocketService\Program.cs:line 47
Aug 26, 2013 at 3:35 AM
Probably it s caused by local environment changes like anti-virus software installation or windows update?

You can fix it by run the command in the command prompt to rebuild the performance counter index:

"Lodctr /r"
Aug 26, 2013 at 1:18 PM
This fixed my issue. Thanks!

I am very happy with your code. You have saved me a lot of work on a project with which I am involved.

Scott
Aug 26, 2013 at 4:41 PM
I am glad to hear that!