.net WinDbg中出现“SOS版本与您调试的CLR版本不匹配”怎么办?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7430769/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What to do with "The version of SOS does not match the version of CLR you are debugging" in WinDbg?
提问by Shrike
I'm having a problem with some of my apps. It's a wcf-based app running under IIS6 in Windows 2003 Server (x86):
In Event Log I get such an error from "W3SVC-WP" source (EventID=2262):
我的某些应用程序有问题。它是在 Windows 2003 Server (x86) 中的 IIS6 下运行的基于 wcf 的应用程序:
在事件日志中,我从“W3SVC-WP”源 (EventID=2262) 收到这样一个错误:
ISAPI 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll' reported itself as unhealthy for the following reason: 'Deadlock detected'.
I'm trying figuring out what's going on. I've set up creating dump for Orphan Worker Process as described in this KB.
When an deadlock occured a minidump is created.
Then I take this minidump to try to understand what's happened. Here's I'm stuck.
我正在尝试弄清楚发生了什么。我已经按照此KB 中的说明设置了为孤儿工作进程创建转储。当发生死锁时,会创建一个小型转储。
然后我利用这个小型转储试图了解发生了什么。这是我卡住了。
I run WinDbg x86, open my dump and then:
我运行 WinDbg x86,打开我的转储,然后:
0:037> .loadby sos clr
0:037> .sympath SRV*c:\temp\symbols*http://msdl.microsoft.com/download/symbols
Symbol search path is: SRV*c:\temp\symbols*http://msdl.microsoft.com/download/symbols
Expanded Symbol search path is: srv*c:\temp\symbols*http://msdl.microsoft.com/download/symbols
0:037> !clrstack
The version of SOS does not match the version of CLR you are debugging. Please load the matching version of SOS for the version of CLR you are debugging.
CLR Version: 4.0.30319.1
SOS Version: 4.0.30319.235
CLRDLL: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscordacwks.dll:4.0.30319.235 f:8 doesn't match desired version 4.0.30319.01 f:8
CLRDLL: Loaded DLL c:\temp\symbols\mscordacwks_x86_x86_4.0.30319.01.dllBA1D9EF66f000\mscordacwks_x86_x86_4.0.30319.01.dll
OS Thread Id: 0x690 (37)
Unable to walk the managed stack. The current thread is likely not a managed thread.
You can run !threads to get a list of managed threads in the process
What to do with this error- "The version of SOS does not match the version of CLR you are debugging" ?
如何处理此错误- “SOS 版本与您正在调试的 CLR 版本不匹配”?
The same error ("The version of SOS does not match the version of CLR you are debugging") I'm getting when I open the minidump in VS2010.
在 VS2010 中打开小型转储时遇到相同的错误(“SOS 版本与您正在调试的 CLR 版本不匹配”)。
I've read this post - http://tech-thinker.com/Forums/tabid/62/forumid/12/postid/471/scope/posts/Default.aspx, and tried installing KB2518870. It doesn't help.
我读过这篇文章 - http://tech-thinker.com/Forums/tabid/62/forumid/12/postid/471/scope/posts/Default.aspx,并尝试安装KB2518870。它没有帮助。
采纳答案by Paul Williams
WinDbg will not be able to use the debugging adapter mscordacwks.dll unless it is the same version as the one from the original machine. You can get around this error by copying this DLL from the target machine which generated the dump to your Debugging Tools for Windows directory.
WinDbg 将无法使用调试适配器 mscordacwks.dll,除非它与原始机器上的版本相同。您可以通过将此 DLL 从生成转储的目标机器复制到您的 Windows 调试工具目录来解决此错误。
We debug .NET 2.0 applications with WinDbg. We would continually get this same error regarding mscordacwks_x86_x86_2.0.50727.3615.dll. I had to copy this file from the server onto my client and put it in the C:\Program Files\Debugging Tools for Windows (x86)\ folder. WinDbg stopped complaining after that.
我们使用 WinDbg 调试 .NET 2.0 应用程序。我们会不断收到关于 mscordacwks_x86_x86_2.0.50727.3615.dll 的相同错误。我必须将此文件从服务器复制到我的客户端,并将其放在 C:\Program Files\Debugging Tools for Windows (x86)\ 文件夹中。在那之后,WinDbg 不再抱怨了。
If all else fails, you can try debugging with WinDbg on the same server from which you retrieved the crash dump.
如果所有其他方法都失败了,您可以尝试在从中检索故障转储的同一台服务器上使用 WinDbg 进行调试。
回答by Thomas Bratt
This is what worked for me:
这对我有用:
Download the following DLLs:
下载以下 DLL:
- clr.dll
- mscordacwks.dll
- SOS.dll
- dll文件
- mscordacwks.dll
- 求救文件
from this folder on the machine that generated the dump:
从生成转储的机器上的这个文件夹:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319
C:\Windows\Microsoft.NET\Framework64\v4.0.30319
Run the following command. The path to SOS.DLL should be without quotes, unescaped path delimiters:
运行以下命令。SOS.DLL 的路径应该没有引号,未转义的路径分隔符:
.load path to downloaded SOS.DLL
.load路径下载SOS.DLL
I think a new WinDbg session is required for this to work.
我认为需要一个新的 WinDbg 会话才能工作。
回答by Ohad Schneider
The core problem usually lies with a mismatching mscordacwks.dllversion (mscorwks.dllitself should not be needed if a full dump was taken). In theory, it should be attainable from the symbol server - simply run .cordll -ve -u -l. For more information on mscordacwks.dllsee Failed to load data access DLL, 0x80004005” – OR – What is mscordacwks.dll.
核心问题通常在于mscordacwks.dll版本不匹配(mscorwks.dll如果进行了完整转储,则不需要它本身)。理论上,它应该可以从符号服务器获得 - 只需运行.cordll -ve -u -l. 有关详细信息,mscordacwks.dll请参阅无法加载数据访问 DLL,0x80004005” – 或 – 什么是 mscordacwks.dll。
Unfortunately, some versions of mscordacwks.dllhave not been indexed, meaning the above won't always work. In such cases you could try and get the correct version from the machine on which the dump was taken, as Yocahiand Thomasmentioned (e.g. from C:\Windows\Microsoft.NET\Framework64\v4.0.30319). Once you get it, issue the following command to load it: .cordll -u -ve -lp PathToFolderContainingMscorDAC. Of course, that machine may be inaccessible, or it may have been patched since the time the dump was taken.
不幸的是,有些版本mscordacwks.dll尚未编入索引,这意味着上述内容并不总是有效。在这种情况下,您可以尝试从进行转储的机器上获取正确的版本,正如Yocahi和Thomas提到的(例如来自C:\Windows\Microsoft.NET\Framework64\v4.0.30319)。一旦你得到它,发出以下命令来加载它:.cordll -u -ve -lp PathToFolderContainingMscorDAC. 当然,那台机器可能无法访问,或者它可能在进行转储后就已经打过补丁。
Fortunately, there is a way to extract mscorwdacwks.dll from the actual update KB package(it resides in one of the cabfiles inside the self extracting executable - use a tool such as 7-Zipto extract it). There also exist repositories of .NET updates (courtesy of MS employee Doug Stewart), so you can browse them for the exact build number you require:
幸运的是,有一种方法可以从实际更新 KB 包中提取 mscorwdacwks.dll(它驻留在cab自解压可执行文件中的一个文件中 - 使用7-Zip等工具来提取它)。还有 .NET 更新存储库(由 MS 员工 Doug Stewart 提供),因此您可以浏览它们以获取所需的确切版本号:
Once you have the correct mscordacwks.dll, the SOS.dllwarning could be ignored in most cases, as the most recent SOS.dllversion would work most of the time despite the warning. However, in some cases the correct SOS.dllversion is needed as well (and as a bonus you get rid of the pesky warnings). Dunkenlinks to a blog postthat should be helpful in that regard (basically you need to place the symbol server in the _NT_SYMBOL_PATHenvironment variable and run !analyze –vwithout loadingSOS.dllfirst - it will load the correct version itself). If that doesn't work, you could try extracting SOS.dllfrom one of the update packages as described above. This sitemay prove easier to use for that purpose, as it specifically indexes SOS.dllversions.
一旦您获得了正确的mscordacwks.dll,SOS.dll在大多数情况下可以忽略警告,因为SOS.dll尽管有警告,最新版本在大多数情况下都可以工作。但是,在某些情况下,SOS.dll还需要正确的版本(作为奖励,您可以摆脱讨厌的警告)。Dunken链接到在这方面应该有帮助的博客文章(基本上,您需要将符号服务器放在_NT_SYMBOL_PATH环境变量中并在!analyze –v不SOS.dll首先加载的情况下运行- 它会加载正确的版本本身)。如果这不起作用,您可以尝试SOS.dll从上述更新包之一中提取。该站点可能更容易用于该目的,因为它专门索引SOS.dll版本。
Finally, consider PsscorR2(for .NET 2.0-3.5) and Psscor4(for .NET 4.0). Psscoris a superset of SOS.dllwhich doesn't complain about mismatched versions, so long as you're using the appropriate major version. It should be noted that over time, it hasn't been maintained as well as SOS.dll, so the latter may include enhancements and bug fixes absent from the former. At the time of writing there was no Psscorversion for .NET 4.5.
最后,考虑PsscorR2(适用于 .NET 2.0-3.5)和Psscor4(适用于 .NET 4.0)。Psscor是一个超集,SOS.dll它不会抱怨版本不匹配,只要您使用适当的主要版本。应该注意的是,随着时间的推移,它的维护不如SOS.dll,因此后者可能包括前者所没有的增强和错误修复。在撰写本文时,没有Psscor适用于 .NET 4.5 的版本。
回答by Yochai Timmer
The version of SOS does not match the version of CLR you are debugging. Please load the matching version of SOS for the version of CLR you are debugging.
CLR Version: 4.0.30319.1
SOS Version: 4.0.30319.235
This means the target machine which made the dump is running on CLR version 4.0.30319.1.
Your system is running with version 4.0.30319.235.
这意味着进行转储的目标机器正在 CLR 版本上运行 4.0.30319.1。
您的系统正在运行版本4.0.30319.235.
This is because there was a security update to .Net 4.0 which changed the CLRand SOSfiles. And some computers may not have this update yet.
这是因为 .Net 4.0 的安全更新更改了CLR和SOS文件。并且某些计算机可能还没有此更新。
See: http://support.microsoft.com/kb/2572078
请参阅:http: //support.microsoft.com/kb/2572078
This may cause some of the lines in the stack to be a bit wrong...
You can avoid the error by obtaining the SOS.dlland CLR.dlland mscordacwks.dlland mscorwks.dllof the original version and load those when you load the SOS.
The original files are usualy under : C:\Windows\Microsoft.NET\Framework\v4.0.30319
Depends on the framework version... and then copy them to a specific folder.
Load the correct files like this:
这可能会导致堆栈中的某些行有点错误......您可以通过获取原始版本的SOS.dll和CLR.dll以及mscordacwks.dll和mscorwks.dll并加载它们来避免错误加载 SOS。
原始文件通常在:C:\Windows\Microsoft.NET\Framework\v4.0.30319
取决于框架版本...然后将它们复制到特定文件夹。
像这样加载正确的文件:
.load C:\CurrectFiles\sos
Note that it's just "sos" and not sos.dll.
请注意,它只是“sos”而不是 sos.dll。
回答by Dunken
You can automatically load the right SOS.dll. Check out John Robbins' great blog post http://wintellect.com/blogs/jrobbins/automatically-load-the-right-sos-for-the-minidump
您可以自动加载正确的 SOS.dll。查看 John Robbins 的精彩博文http://wintellect.com/blogs/jrobbins/automatically-load-the-right-sos-for-the-minidump
You also might to check with .chainwhat's already loaded. In some cases you have to unload (e.g. .unload sos) the wrongly loaded dlls first.
您还可以检查.chain已加载的内容。在某些情况下,您必须先卸载(例如.unload sos)错误加载的 dll。
回答by mistika
In short, do the following:
简而言之,请执行以下操作:
- Get the CLR version form the dump
- Find and download appropriate Microsoft patch
- Extract the sos.dlland mscordacwks.dllfrom the patch
- Use it
- 从转储中获取 CLR 版本
- 查找并下载适当的 Microsoft 补丁
- 从补丁中提取sos.dll和mscordacwks.dll
- 用它
Below is an example:
下面是一个例子:
1.After loading a crash dump I get the version I need:
1.加载故障转储后,我得到了我需要的版本:
>lm vm clr
it gives me
它给了我
File version: 4.0.30319.18051
2.I google for MS update that contains this version:
2.我在谷歌上搜索包含此版本的 MS 更新:
In this case google gives an MS KB pagewith a download link. I usually download x64 version, because it contains both x86 and x64 dlls, so I have Windows8-RT-KB2833958-x64.msunow.
在这种情况下,谷歌提供了一个带有下载链接的MS KB 页面。我通常下载 x64 版本,因为它包含 x86 和 x64 dll,所以我现在有Windows8-RT-KB2833958-x64.msu。
Note:sometimes it's tricky to get the required patch, but not in this example.
注意:有时很难获得所需的补丁,但在本例中并非如此。
3.Using FAR file managerI extract cabinet archive from this MSU:
3.使用FAR 文件管理器,我从这个 MSU 中提取文件柜档案:
Windows8-RT-KB2833958-x64.cab
Windows8-RT-KB2833958-x64.cab
Note:Sometimes there're several cabinets inside, so you need to check which one contains sos.dll.
注意:有时里面有好几个柜子,需要查看哪个柜子里有sos.dll。
Note:Sometimes patches are distributed as .EXE, so you first need to extract MSU or MSP files (I do it with FAR), and then extract cabinets from them.
注意:有时补丁是作为 .EXE 分发的,因此您首先需要提取 MSU 或 MSP 文件(我使用 FAR 进行),然后从中提取文件柜。
4.Sometimes files from CABs can be extracted by FAR, but sometimes they have very different structure and I use Expand.exefrom WinAIK. WinAIK is 1.7 Gb ISO, but you need only a small part. I use the following BAT file
4.有时从CAB的文件,可以通过FAR中提取,但有时他们有很不同的结构和我使用的Expand.exe从WinAIK。WinAIK 是 1.7 Gb ISO,但您只需要一小部分。我使用以下BAT文件
mkdir Extracted
..\winaik_amd64\servicing\Expand.exe "%1" -F:sos.dll "Extracted"
..\winaik_amd64\servicing\Expand.exe "%1" -F:mscordacwks.dll "Extracted"
This command extracts all versions of specified dlls, each one inside its own dir. Sometimes there're 2 versions of both mscordacwks.dll and sos.dll. I believe this is because of GRD/LDR(QFE) staff. In our example there're 4.0.30319.18051and 4.0.30319.19079. Check file properties with Windows Explorer.
此命令提取指定 dll 的所有版本,每个版本都在其自己的目录中。有时 mscordacwks.dll 和 sos.dll 都有 2 个版本。我相信这是因为 GRD/LDR(QFE) 员工。在我们的示例中,有 4.0.30319。18051和4.0.30319。19079 年。使用 Windows 资源管理器检查文件属性。
5.Rename the files appropriately: mscordacwks.dllmust be named as mscordacwks_%arch%_%arch%_%version%.dlland placed near the sos.dll
5.适当重命名文件:mscordacwks.dll必须命名为mscordacwks_%arch%_%arch%_%version%.dll并放置在sos.dll附近
So mscordacwks.dll(4.0.30319.18051) goes to mscordacwks_AMD64_AMD64_4.0.30319.18051.dll
所以 mscordacwks.dll( 4.0.30319.18051) 转到mscordacwks_AMD64_AMD64_4.0.30319.18051.dll
(x86 version rename to mscordacwks_x86_x86_4.0.30319.18051.dll)
(x86 版本重命名为mscordacwks_ x86_x86_4.0.30319.18051.dll)
sos.dll might stay as is intact, but I rename it to sos.4.0.30319.18051.dll
sos.dll 可能保持原样,但我将其重命名为sos.4.0.30319.18051.dll
Do the same for 4.0.30319.19079 version (for possible future needs)
对 4.0.30319.19079 版本做同样的事情(为了将来可能的需要)
6.Copy these files to 'C:\SOS\' folder which contains a lot of sos.4.x.x.x.dlland mscordacwks_AMD64_AMD64_4.x.x.x.dll
6.将这些文件复制到'C:\SOS\'文件夹,里面有很多sos.4.xxxdll和mscordacwks_AMD64_AMD64_4.xxxdll
7.Use it with
7.使用它
.load C:\SOS\sos.4.0.30319.18051.dll
Note:Sometimes for .Net 4.5 you need to add additional '0' to mscordacwks version mscordacwks_AMD64_AMD64_4.6.1055.00.dll instead of mscordacwks_AMD64_AMD64_4.6.1055.0.dll. I didn't dig deeper though, because could handle this within a small timeframe.
注意:有时对于 .Net 4.5,您需要向 mscordacwks 版本 mscordacwks_AMD64_AMD64_4.6.1055 添加额外的“0”。00.dll 而不是 mscordacwks_AMD64_AMD64_4.6.1055。0.dll文件。不过我没有深入挖掘,因为可以在很短的时间内处理这个问题。
BTW, WinDbg will say if mscordacwks cannot be found and will specify the version (which will have double '0' at the end).
顺便说一句,WinDbg 会说是否找不到 mscordacwks 并指定版本(最后会有双“0”)。

