无法找到运行时 clr.dll 以使用 sos [英] Failed to find runtime clr.dll to use sos

查看:41
本文介绍了无法找到运行时 clr.dll 以使用 sos的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的控制台应用程序(目标框架 4.5.2):

I have simple console application (target framework 4.5.2):

using System;

public class SosTest
{
    public class Foo
    {
        public Foo()
        {
            Console.WriteLine("Creation of foo");
        }
    }

    static void Main(string[] args)
    {
        var n1 = new Foo();
        var n2 = new Foo();
        Console.WriteLine("Allocated objects");
        Console.WriteLine("Press any key to invoke GC");
        Console.ReadKey();
        n2 = n1;
        n1 = null;
        GC.Collect();
        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
    }
}

我想查看托管堆的状态.我执行以下步骤:

I want to see state of managed heap. I do following steps:

  1. 打开windbg
  2. 使用windbg的打开可执行文件"命令打开我的程序的exe文件
  3. 执行命令加载 sos .load MicrosoftNet\Framework\v4.0.30319\sos.dll
  4. 执行命令查看堆状态 !eeheap -gc

但在最后一个命令中,我收到以下消息:

But during last command I get following message:

未能找到运行时 DLL (clr.dll),0x80004005扩展命令需要 clr.dll 才能有事情做.

Failed to find runtime DLL (clr.dll), 0x80004005 Extension commands need clr.dll in order to have something to do.

为什么命令 !eeheap -gc 会失败?

Why does command !eeheap -gc fail?

如果它会帮助它是 lm 命令的结果:

If it will help it is result of lm command:

0:000> lm
start    end        module name
00be0000 00be8000   ConsoleApplication1   (deferred)            
734c0000 73519000   MSCOREE    (deferred)             
74c20000 74d00000   KERNEL32   (deferred)             
753d0000 75571000   KERNELBASE   (deferred)             
77d80000 77f03000   ntdll      (pdb symbols)

推荐答案

我不确定您的做法是否正确,但我曾经使用以下命令进行操作:

I am not sure you are doing it right way or not, but i used to do it with the following command:

sxe ld clrjit; g

然后写:

.loadby sos clr

sxe ld clrjitclrjit 模块 加载时通知调试器,g 标志用于继续执行和 .loadby sosclr 将从找到 clr.dll

the sxe ld clrjit notifies debugger when clrjit module is loaded, the g flag is for continuing execution and .loadby sos clr will load sos debugger from location where it finds clr.dll

我曾经看过以下两门关于 C# Internals 的复数课程,作者是Bart de Smet,我发现它们非常适合理解 c# 和 clr 的见解:

I once watched the following the following two plural-sight courses on C# Internals by Bart de Smet and i found them great for understanding the insights of c# and clr:

C# 语言内部结构 - 第 1 部分

C# 语言内部原理 - 第 2 部分

这篇关于无法找到运行时 clr.dll 以使用 sos的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆