Ejemplo n.º 1
0
        public IEnumerable EnumAppDomains()
        {
            ICorPublishAppDomainEnum pIEnum;

            m_process.EnumAppDomains(out pIEnum);
            return((pIEnum == null) ? null : new CorPublishAppDomainEnumerator(pIEnum));
        }
Ejemplo n.º 2
0
        void EnumAppDomainsShown(object sender, EventArgs e)
        {
            ICorPublish publish = (ICorPublish) new CorpubPublish();

            if (publish != null)
            {
                ICorPublishProcess ppProcess = null;
                try
                {
                    publish.GetProcess((uint)procid, out ppProcess);
                }
                catch
                {
                }

                if (ppProcess != null)
                {
                    bool IsManaged = false;
                    ppProcess.IsManaged(out IsManaged);
                    if (IsManaged)
                    {
// Enumerate the domains within the process.
                        ICorPublishAppDomainEnum ppEnum = null;
                        ppProcess.EnumAppDomains(out ppEnum);

                        ICorPublishAppDomain pappDomain; // ICorPublishAppDomain
                        uint aFetched = 0;
                        while (ppEnum.Next(1, out pappDomain, out aFetched) == 0 && aFetched > 0)
                        {
                            StringBuilder szName = null;
                            try
                            {
                                uint pcchName = 0;
                                pappDomain.GetName(0, out pcchName, null);
                                szName = new StringBuilder((int)pcchName);
                                pappDomain.GetName((uint)szName.Capacity, out pcchName, szName);
                            }
                            catch
                            {
                            }

                            string appdomainname = szName.ToString();
                            uint   appdomainid   = 0;
                            pappDomain.GetID(out appdomainid);

                            ListViewItem appdomaintoadd = new ListViewItem(new string[] { appdomainid.ToString(), appdomainname });
                            lvdomains.Items.Add(appdomaintoadd);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Selected process is not a managed .NET process!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show("Failed to open slected process \r\n" +
                                    "maybe is not a .NET process!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }