使用VS 2012 + IIsExpress8时,performanceCounter挂起

时间:2013-10-23 08:32:01

标签: visual-studio-2012 iis-express performancecounter

我试图在几天后弄清楚这个,所以我想出了一个测试用例:

  • 启动一个新的asp.net mvc项目
  • HomeController.Index上的
  • 替换代码

    var test = new PerformanceCounter(“toto”,“cac”);  返回内容(“toto”);

  • 确保已设置为使用IIS Express

  • 在调试
  • 上启动项目

在我的机器上,它永远挂在PerformanceCounter线上。如果我是停止按钮,我可以看到以下statcktrace:

[Managed to Native Transition]  
mscorlib.dll!Microsoft.Win32.RegistryKey.InternalGetValue(string name, object defaultValue, bool doNotExpand, bool checkSecurity) + 0x5ae bytes 
mscorlib.dll!Microsoft.Win32.RegistryKey.GetValue(string name) + 0x29 bytes 
System.dll!System.Diagnostics.PerformanceMonitor.GetData(string item) + 0x67 bytes  
System.dll!System.Diagnostics.PerformanceCounterLib.GetPerformanceData(string item) + 0xbb bytes    
System.dll!System.Diagnostics.PerformanceCounterLib.CategoryTable.get() + 0x6a bytes    
System.dll!System.Diagnostics.PerformanceCounterLib.CounterExists(string category, string counter, ref bool categoryExists) + 0x1a bytes    
System.dll!System.Diagnostics.PerformanceCounterLib.CounterExists(string machine, string category, string counter) + 0x4f bytes 
System.dll!System.Diagnostics.PerformanceCounter.InitializeImpl() + 0x2eb bytes 
System.dll!System.Diagnostics.PerformanceCounter.PerformanceCounter(string categoryName, string counterName, string instanceName, bool readOnly) + 0x98 bytes   
System.dll!System.Diagnostics.PerformanceCounter.PerformanceCounter(string categoryName, string counterName) + 0x13 bytes   
  

TestPerfCounter.dll!TestPerfCounter.Controllers.HomeController.Index()第17行+ 0x21字节C#

有什么想法吗?如果我切换到开发服务器,它就不会挂起......

1 个答案:

答案 0 :(得分:0)

我终于找到了解决方案:

http://support.microsoft.com/kb/300956

我不知道为什么,但它解决了

  

重建基本性能指标

     

可扩展计数器信息存储在以下两个中   locations:以下注册表子项:   HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Windows NT \ Current   Version \ Perflib \ 009%Systemroot%\ System32 \ Perfc009.dat文件和   %Systemroot%\ System32 \ Perfh009.dat文件要重建基础   手动执行性能计数器库,请按照下列步骤操作:展开   Perfc009.dat文件和Perfh009.dat文件。这些文件位于   在Windows安装光盘上。压缩文件位于   DriveLetter:\ i386 \ perfc009.da_和DriveLetter:\ i386 \ perfh009.da_。   替换%Systemroot%\ System32文件夹中的文件。开始   注册表编辑器,然后在注册表中找到以下项:   HKEY_LOCAL_MACHINE \ SOFTWARE \微软\的Windows   NT \ CurrentVersion \ Perflib在注册表中,更改最后一个计数器   值为1846(十进制),并将“上一个帮助”值更改为1847   (十进制)。找到以下注册表项以搜索服务   有一个Performancesubkey:   HKEY_LOCAL_MACHINE \ System \ CurrentControlSet \ Services删除   Performance子项中的以下值(如果存在):首先   计数器第一帮助最后一个计数器上一个帮助您也可以使用   Exctrlst.exe工具用于定位性能计数器动态链接   安装的库文件(DLL),然后访问注册表   删除DWORD值。你现在有一个可行的表现   只包含系统基础计数器的注册表。

     

注意从注册表中的Performance子项中删除值   可能导致任何已安装的.NET Framework应用程序无法运行   下次他们开始。如果发生这种情况,请使用lodctr / R.   命令在“重新添加可扩展计数器”部分中重建   表现计数器。如果你开始时仍然有问题   .NET Framework应用程序,请参阅“重新安装任何自定义.NET”   框架组装性能计数器“在本文中的部分。

相关问题