为什么调用程序集不显示在 c# 中的当前应用程序域中?

Why doesn't the calling assembly show up in the current app domain in c#?

我正在使用 MonoDevelop,我在同一个解决方案中有一个库项目和一个 NUnit 项目。 NUnit 项目引用库并包含我的测试。我想测试的一些行为涉及检查加载的程序集中的类型和方法。我尝试使用 AppDomain.CurrentDomain.GetAssemblies() 但库和 NUnit 测试都不在这些程序集中。我确定我在这里误解了一些东西,但我希望能在这里找到它们。我可以通过调用 AppDomain.GetExecutingAssembly() 来获取库,通过调用 AppDomain.GetCallingAssembly() 来获取测试,但根据我阅读的内容,后者并不完全可靠(因为一件事可能内联)。

有人可以帮我弄清楚为什么执行程序集和调用程序集不在当前应用程序域中吗?是否可以循环包含这两个程序集的集合?我发现 an example 循环遍历所有应用程序域,但它需要 mscoree,这在 MonoDevelop 中不可用。

遵循 NUnit 的文档:https://github.com/nunit/docs/wiki/Assembly-Isolation 程序集被加载到不同的 AppDomain 中。所以与 AppDomain.CurrentDomain.GetAssemblies() 你永远不会得到你的程序集。