使用windbg可以調試asp.net中數據庫連接池是否超限的問題。詳見文章:
A:請先用.chain命令查看是否已經導入clr擴展:
我主要其實想說明的是,在搭建調試環境和進行調試過程中可能碰到的幾個問題:
1. The call to LoadLibrary(C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll) failed
0:000> .load C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll The call to LoadLibrary(C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll) failed, Win32 error 0n193 "%1 is not a valid Win32 application." Please check your debugger configuration and/or network access.
A:檢查你的windbg版本,是否為x86,估計你現在用的是x64,你想導入x86的clr.dll肯定出錯了...換個windbg或者導入:
.load C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
2. Failed to find runtime DLL (clr.dll), 0x80004005
0:000> !dumpheap Failed to find runtime DLL (clr.dll), 0x80004005 Extension commands need clr.dll in order to have something to do.
0:000> .chain Extension DLL search Path: ...//省略 Extension DLL chain: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll: image 4.0.30319.239, built Sat Jul 09 17:44:20 2011 [path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll] C:\Windows\Microsoft.NET\Framework64\v4.0.30319\SOS.dll: image 4.0.30319.239, API 1.0.0, built Sat Jul 09 18:00:43 2011 [path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\SOS.dll] dbghelp: image 6.12.0002.633, API 6.1.6, built Tue Feb 02 04:15:44 2010 [path: D:\WinDDK\7600.16385.1\Debuggers\dbghelp.dll] ext: image 6.12.0002.633, API 1.0.0, built Tue Feb 02 04:15:46 2010 [path: D:\WinDDK\7600.16385.1\Debuggers\winext\ext.dll] exts: image 6.12.0002.633, API 1.0.0, built Tue Feb 02 04:15:38 2010 [path: D:\WinDDK\7600.16385.1\Debuggers\WINXP\exts.dll] uext: image 6.12.0002.633, API 1.0.0, built Tue Feb 02 04:15:36 2010 [path: D:\WinDDK\7600.16385.1\Debuggers\winext\uext.dll] ntsdexts: image 6.1.7650.0, API 1.0.0, built Tue Feb 02 04:15:18 2010 [path: D:\WinDDK\7600.16385.1\Debuggers\WINXP\ntsdexts.dll]
如果已經導入了clr.dll,但是還是不行,那么估計你調試的是一個dump文件或者程序已經跑完。建議在程序即將結束處加個sleep,讓程序等待在那里,並且通過Open Excutable...的方式打開程序后,按g讓程序先跑起來,等掛起的時候,再按CTRL+BREAK,讓程序暫停,這個時候再倒入sos和clr擴展。現在再輸入!dumpheap應該就可以了。(參考:http://social.msdn.microsoft.com/Forums/en-US/clr/thread/59aa78c9-dc05-43c8-9efe-e7b132056afc/)