关于C#调试中缺少CategoryName

网上有些文章是写这方面的,其解决方法都是说删除:
((System.ComponentModel.ISupportInitialize)(this.performanceCounter1)).EndInit();
这是个傻瓜方法,虽然简单,但是会出问题
什么是CategoryName ?
这只不过是控件要用的名字,当你添加
performanceCounte
之类的控件时,它会要求生成CategoryName ,但vs这次傻了,它不会自动生成CategoryName ,所以才报错。
真正的解决方法是:
在Form1.Designer中添加
this.performanceCounter1.CategoryName = "Processor";
this.performanceCounter1.CounterName = "% Processor Time";
this.performanceCounter1.InstanceName = "_Total";
这三行代码就OK了

PS:
这是我第一个博客文章。

posted @ 2012-03-26 16:26  王之  阅读(620)  评论(0编辑  收藏  举报