示例#1
0
        /// <summary>
        /// Registers the types in the specified assembly.
        /// </summary>
        public static void UnregisterAssembly(string filePath)
        {
            List <System.Type> types = ConfigUtils.UnregisterComTypes(filePath);

            foreach (System.Type type in types)
            {
                try
                {
                    ConfigUtils.UnregisterClassInCategory(type.GUID, ConfigUtils.CATID_DotNetOpcServers);
                }
                catch
                {
                    continue;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Removes the registration for a COM server from the registry.
        /// </summary>
        public static void UnregisterComServer(Guid clsid)
        {
            // unregister class in categories.
            string categoriesKey = String.Format(@"CLSID\{{{0}}}\Implemented Categories", clsid);

            RegistryKey key = Registry.ClassesRoot.OpenSubKey(categoriesKey);

            if (key != null)
            {
                try
                {
                    foreach (string catid in key.GetSubKeyNames())
                    {
                        try
                        {
                            ConfigUtils.UnregisterClassInCategory(clsid, new Guid(catid.Substring(1, catid.Length - 2)));
                        }
                        catch (Exception)
                        {
                            // ignore errors.
                        }
                    }
                }
                finally
                {
                    key.Close();
                }
            }

            string progidKey = String.Format(@"CLSID\{{{0}}}\ProgId", clsid);

            // delete prog id.
            key = Registry.ClassesRoot.OpenSubKey(progidKey);

            if (key != null)
            {
                string progId = key.GetValue(null) as string;
                key.Close();

                if (!String.IsNullOrEmpty(progId))
                {
                    try
                    {
                        Registry.ClassesRoot.DeleteSubKeyTree(progId);
                    }
                    catch (Exception)
                    {
                        // ignore errors.
                    }
                }
            }

            // delete clsid.
            try
            {
                Registry.ClassesRoot.DeleteSubKeyTree(String.Format(@"CLSID\{{{0}}}", clsid));
            }
            catch (Exception)
            {
                // ignore errors.
            }
        }