.net - 列出进程中的 AppDomain

标签 .net process appdomain

是否有可能如何枚举 Process 中的 AppDomain?

最佳答案

您可能想查看this post

using System.Runtime.InteropServices;
// Add the following as a COM reference - C:\WINDOWS\Microsoft.NET\Framework\vXXXXXX\mscoree.tlb
using mscoree;                              

        public static IList<AppDomain> GetAppDomains()
        {
            IList<AppDomain> _IList = new List<AppDomain>();
            IntPtr enumHandle = IntPtr.Zero
            CorRuntimeHostClass host = new mscoree.CorRuntimeHostClass();
            try
            {
                host.EnumDomains(out enumHandle);
                object domain = null;
                while (true)
                {
                    host.NextDomain(enumHandle, out domain);
                    if (domain == null) break;
                    AppDomain appDomain = (AppDomain)domain;
                    _IList.Add(appDomain);
                }
                return _IList;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return null;
            }
            finally
            {
                host.CloseEnum(enumHandle);
                Marshal.ReleaseComObject(host);
            }
        } 
    }

关于.net - 列出进程中的 AppDomain,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/388554/

相关文章:

c# - 模式验证在验证之前不修剪字符串

c# - 项目不引用框架,但它确实

c# - 用于视频播放的 .NET FFmpeg 包装器

python - 执行嵌入在 Python 脚本中的 .exe 文件

c - 当子进程执行 execvp 时,waitpid 未收到退出状态

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

.net - 如何在 VS 2005 中关闭无 xml 注释的警告

visual-studio - 在VS Community 2017中的哪里找到Microsoft.TeamFoundation.Build.Workflow.dll

c# - 如何序列化第 3 方类型以跨 AppDomain 进行通信?

c# - 试图避免 AppDomains