This is the code that creates the performance counter:
var ftpPerfCounter = new PerformanceCounter("FTP Service", "Current Connections", "_Total");
This is where the exception happens:
int cnt = (int)Math.Round(ftpPerfCounter.NextValue());
Here's the Exception
message:
"Error Message: The Counter layout for the Category specified is invalid, a counter of the type: AverageCount64, AverageTimer32, CounterMultiTimer, CounterMultiTimerInverse, CounterMultiTimer100Ns, CounterMultiTimer100NsInverse, RawFraction, or SampleFraction has to be immediately followed by any of the base counter types: AverageBase, CounterMultiBase, RawBase or SampleBase."
The error message is pretty cryptic. I am not sure what can be done to avoid the exception in the future.
Details
This happens on Windows Server 2008 R2 64-bit OS. The FTP Server is IIS.