无法解决System.ArgumentException

时间:2015-05-09 23:16:43

标签: c#

我想查看 PerformanceCounter名称并创建控制台应用以查看它。但有一个错误。帮助解决问题

Console.WriteLine(Environment.MachineName);
PerformanceCounterCategory[] categories;
PerformanceCounter[] pfs;

categories = PerformanceCounterCategory.GetCategories();

foreach (PerformanceCounterCategory category in categories) {
    //Console.WriteLine("-> {0} - {1}", category.CategoryName, category.CategoryType);
    try {
        pfs = category.GetCounters();

        foreach (PerformanceCounter pc in pfs) {
            //Console.WriteLine("\t->{0}", pc.CounterName);
        }
    }
    catch (Exception ex) {
        try {
            InstanceDataCollectionCollection idcc = category.ReadCategory();
            foreach (InstanceDataCollection v in idcc.Values) {
                //Console.WriteLine("\t->{0}", v.CounterName);
            }
        }
        catch (Exception exx) {
            Console.WriteLine(exx.Message);
        }
    }
}

Console.WriteLine("\n**********************************************\n");
  

中的“System.ArgumentException”类型的未处理异常   mscorlib.dll中

     

有关详细信息:已添加项目。键入字典:   “每秒发送请求数”键被添加:“每秒发送请求数”

0 个答案:

没有答案