Reputation: 43
I was executing code below :
class Program
{
static void Main(string[] args)
{
PerformanceCounter performanceCounter = new PerformanceCounter("Network Interface", "Bytes Sent/sec", "Intel(R) 82579V Gigabit Network Connection");
Console.WriteLine(performanceCounter.NextValue().ToString());
}
}
I'm getting this exception.
An unhandled exception of type 'System.InvalidOperationException' occurred in System.dll Additional information: Instance 'Intel(R) 82579V Gigabit Network Connection' does not exist in the specified Category.
I have tested the parameters with windows perfmon tool , it was working but in code its giving exception.
Can anybody please help..
Upvotes: 0
Views: 1512
Reputation: 67
Have you checked if the name is spelled correctly? Even with a minor error, this most likely won't work.
To check which names exist in this category, try (as suggested here: https://stackoverflow.com/a/29270209/1648463)
PerformanceCounterCategory category = new PerformanceCounterCategory("Network Interface");
String[] instancename = category.GetInstanceNames();
foreach (string name in instancename)
{
Console.WriteLine(name);
}
For example, one of the existing names for network interfaces on my computer is
Intel[R] 82579LM Gigabit Network Connection
(with brackets instead of round brackets).
Upvotes: 1