2

我使用Microsoft.Diagnostics.Runtime并尝试分析故障转储,但我的机器上没有匹配的 mscordacwks.dll

请给我一个建议,或者我如何从 Microsoft 的符号服务器获取它?

4

2 回答 2

0

ClrVersion 类现在有一个 TryDownloadDac 方法。您需要在与您正在调试的应用程序(64 位/32 位)中运行的相同架构中运行您的进程,以便成功地将 DAC 库加载到您的进程中。

于 2014-02-28T18:44:16.513 回答
0

缺少 mscordacwks.dll 是我不时使用 WinDbg 查看故障转储文件时遇到的一种痛苦(我注意到您正在尝试使用 ClrMD 来实现相同的最终目标)。通常,microsoft 符号服务器非常全面,但在 mscordacwks.dll 的情况下,并非所有版本都存在于公共符号服务器上(如此处所述。获取匹配的 mscordacwks.dll 版本的最佳方法是从创建故障转储的计算机(以及相应的 .net 框架文件夹)中提取它,以防公共符号服务器出现故障。

老实说,我更像是一个 WinDbg 用户,所以我更习惯在那里处理 mscordacwks,但是通过在谷歌上四处寻找,我确实找到了一些有趣的文章。第一个提到你可以这样做:

// DataTarget.ClrVersions lists the versions of CLR loaded in the process (this may be
// v2 and v4 in the Side-By-Side case.
ClrInfo version = target.ClrVersions[0];

// CLRVersionInfo contains information on the correct Dac dll to load.  This includes
// the long named dac, the version of clr, etc.  This is enough information to request
// the dac from the symbol server (though we do not provide an API to do this).  Also,
// if the version you are debugging is actually installed on your machine, DacLocation
// will contain the full path to the dac.
string dacLocation = version.TryGetDacLocation();

如果这不起作用,那么有人发布了更复杂的DacLocator类的代码。希望这两种途径之一应该适用于加载您需要的 dll 版本。

于 2014-02-09T21:06:36.153 回答