c# - An unhandled exception of type 'System.InvalidOperationException' occurred in System.dll -
i 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 exception.
an unhandled exception of type 'system.invalidoperationexception' occurred in system.dll additional information: instance 'intel(r) 82579v gigabit network connection' not exist in specified category.
i have tested parameters windows perfmon tool , working in code giving exception.
can please help..
have checked if name spelled correctly? minor error, won't work.
to check names exist in 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, 1 of existing names network interfaces on computer is
intel[r] 82579lm gigabit network connection
(with brackets instead of round brackets).
Comments
Post a Comment