简体   繁体   English

System.dll中发生了类型为'System.InvalidOperationException'的未处理异常

[英]An unhandled exception of type 'System.InvalidOperationException' occurred in System.dll

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. System.dll中发生了类型为'System.InvalidOperationException'的未处理异常。其他信息:指定类别中不存在实例'Intel(R)82579V千兆网络连接'。

I have tested the parameters with windows perfmon tool , it was working but in code its giving exception. 我已经使用Windows perfmon工具测试了参数,它正在工作,但是在代码中给出了异常。

Can anybody please help.. 有人可以帮忙吗..

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 ) 要检查此类别中存在哪些名称,请尝试(如此处建议的那样: 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). (使用方括号代替圆括号)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.dll中发生了'System.InvalidOperationException' - 'System.InvalidOperationException' occurred in System.dll WebDriver.dll中发生了未处理的“System.InvalidOperationException”类型异常 - An unhandled exception of type 'System.InvalidOperationException' occurred in WebDriver.dll mscorlib.dll中发生了类型为'System.InvalidOperationException'的未处理异常 - An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll 发生未处理的异常C#的system.data.dll中发生了类型'system.invalidoperationexception'的未处理异常 - An unhandled exception occured an unhandled exception of type 'system.invalidoperationexception' occurred in system.data.dll in c# System.dll 中出现“System.ObjectDisposedException”类型的未处理异常 - An unhandled exception of type 'System.ObjectDisposedException' occurred in System.dll System.Data.dll中发生类型为'System.InvalidOperationException'的未处理异常-C#Visual Studio - An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll - C# visual studio System.Data.dll 430中发生类型为'System.InvalidOperationException'的未处理异常 - An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll 430 System.Data.dll (SqlTransaction) 中出现“System.InvalidOperationException”类型的未处理异常 - An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll (SqlTransaction) System.Data.dll 中发生类型为“System.InvalidOperationException”的未处理异常? - An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll? C# 中的 System.Data.dll 中发生了“System.InvalidOperationException”类型的未处理异常 - An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM