c# - Windbg 和查看 AppDomain 内容

标签 c# windbg appdomain linqpad

我知道我们可以在 winbbg 中使用 !dumpdomain 命令来查看给定托管进程(例如 w3wp)中存在的各种应用程序域。

我在 LinqPad 中编写了一个小程序(来自 Visual C# 2010 Recipes 的 Recipe 3-1 A problem solution approach),以创建自定义 AppDomain。这就是我面临的问题。我无法使用 windbg 查看此应用程序域。换句话说,这个应用域是在哪里创建的?它托管在 LinqPad 进程中吗?如果不是,那么哪个进程正在托管这个自定义应用程序域?

我尝试将 LinqPad.exe 附加到 windbg 并发出 !dumpdomain 命令,但出现以下错误:

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

代码:

void Main()
{
    AppDomainSetup setUpInfo = new AppDomainSetup();

    setUpInfo.ApplicationBase = @"C:\MyRootDirectory";
    setUpInfo.ConfigurationFile = "MyApp.config";
    setUpInfo.PrivateBinPath = "bin;plugins;external";

    AppDomain newDomain = AppDomain.CreateDomain("My New Domain",null,setUpInfo);

    Console.WriteLine("Main method complete.Press Enter");
    Console.ReadLine();
}

遵循的步骤:

  • 运行程序。它等待用户按 Enter。
  • 启动windbg。附上 LinqPad.exe。
  • 发出命令:.load sos.dll 和 .load sosex.dll
  • 发出命令.reload
  • 最后调用 !dumpdomain。此时 LinqPad 卡住。如果我关闭 windbg,那么 LinqPad 也会关闭。

最佳答案

它是在 LINQPad 进程中创建的。您的查询本身在 LINQPad 创建的单独 AppDomain 中运行。错误消息是否与 CLR 版本不匹配有关?您运行的是 LINQPad 2.x 还是 4.x?

关于c# - Windbg 和查看 AppDomain 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8132140/

相关文章:

c# - 将 Unicode 字符串从 C# 发送到 SQL Server 2008 数据库

c# - 如何使用 C# 限制带有 BIOS 日期和时间的试用安装?

.net - Fn 地址不可用

Windows 内核条件断点未评估

c# - 垃圾收集期间崩溃的原因

c# - 如何从 Web API 应用程序的 Bin 目录访问 Xml 文件?

c# - 为每个用户保存业务规则

c# - 我已经使用 LINQ 将 Excel 文件加载到 .NET 中,现在如何将数据批量插入到 DB (oracle) 表中?

c# - .net 4.0 安全模型。另一个 "Inheritance security rules violated by type..."异常

c# - 为什么使用 Thread.CurrentContext 属性和 Thread.GetDomain() 方法?