今天开发人员提交同一个程序的两个dump文件,运行环境Windows Server 2008 R2、.NET Framework 2.0。当使用WinDbg分析第二个文件时,加载sos执行命令提示如下:
0:000> .load C:\Windows\Microsoft.NET\Framework64\v2.0.50727\sos.dll 0:000> !clrstack Failed to find runtime DLL (mscorwks.dll), 0x80004005 Extension commands need mscorwks.dll in order to have something to do.
执行lmvm clr发现CLR为4.0,重新加载4.0版本的sos.dll可以解决该问题。
0:000> lmvm clr start end module name 00000000`71450000 00000000`71abf000 clr (deferred) Image path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Image name: clr.dll Timestamp: Thu Mar 18 15:44:47 2010 (4BA1D9EF) CheckSum: 00671FC0 ImageSize: 0066F000 File version: 4.0.30319.1 Product version: 4.0.30319.1 File flags: 8 (Mask 3F) Private File OS: 4 Unknown Win32 File type: 2.0 Dll File date: 00000000.00000000 Translations: 0409.04b0 CompanyName: Microsoft Corporation ProductName: Microsoft® .NET Framework InternalName: clr.dll OriginalFilename: clr.dll ProductVersion: 4.0.30319.1 FileVersion: 4.0.30319.1 (RTMRel.030319-0100) PrivateBuild: DDBLD766 FileDescription: Microsoft .NET Runtime Common Language Runtime - WorkStation LegalCopyright: © Microsoft Corporation. All rights reserved. Comments: Flavor=Retail
补充一下,由于.NET Framework 4.5的安装实际替换了4.0目录下对应的文件,所以4.0以上版本的更新调试存在3个版本,调试时分别需要相应版本的clr.dll、mscordacwks.dll、sos.dl(v4.0.30319.1、v4.0.30319.17929、v4.0.30319.18010)。