几天以来我一直在尝试解决这个问题,所以我想出了一个测试用例:
- 开始一个新的 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#
任何想法 ?如果我切换到开发服务器它不会挂起......