private void LoadPluginsFromRegistryPaths(PluginLoader pluginLoader, bool showErrors)
        {
            try
            {
                // build list of assemblies
                ArrayList assemblyPaths = new ArrayList();

                // HKCU
                using (SettingsPersisterHelper userSettingsKey = ApplicationEnvironment.UserSettingsRoot.GetSubSettings(PLUGIN_ASSEMBLIES))
                    AddPluginsFromKey(assemblyPaths, userSettingsKey);

                if (_pluginsKey != PLUGIN_LEGACY_KEY)
                    using (RegistryKey legacyKey = Registry.CurrentUser.OpenSubKey(PLUGIN_LEGACY_KEY))
                        if (legacyKey != null) // Don't create the key if it doesn't already exist
                            using (SettingsPersisterHelper legacyUserSettingsKey = new SettingsPersisterHelper(new RegistrySettingsPersister(Registry.CurrentUser, PLUGIN_LEGACY_KEY)))
                                AddPluginsFromKey(assemblyPaths, legacyUserSettingsKey);

                // HKLM (this may not work for limited users and/or on vista)

                try
                {
                    if (ApplicationEnvironment.MachineSettingsRoot.HasSubSettings(PLUGIN_ASSEMBLIES))
                        using (SettingsPersisterHelper machineSettingsKey = ApplicationEnvironment.MachineSettingsRoot.GetSubSettings(PLUGIN_ASSEMBLIES))
                            AddPluginsFromKey(assemblyPaths, machineSettingsKey);

                    if (_pluginsKey != PLUGIN_LEGACY_KEY)
                        using (RegistryKey legacyKey = Registry.LocalMachine.OpenSubKey(PLUGIN_LEGACY_KEY))
                            if (legacyKey != null) // Don't create the key if it doesn't already exist
                                using (SettingsPersisterHelper legacyUserSettingsKey = new SettingsPersisterHelper(new RegistrySettingsPersister(Registry.LocalMachine, PLUGIN_LEGACY_KEY)))
                                    AddPluginsFromKey(assemblyPaths, legacyUserSettingsKey);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Error occurred while attempting to read HKLM for PluginAssemblies: " + ex.ToString());
                }

                // load them
                foreach (string assemblyPath in assemblyPaths)
                    pluginLoader.LoadPluginsFromAssemblyPath(assemblyPath, showErrors);
            }
            catch (Exception ex)
            {
                Trace.Fail("Unexpected exception loading plugins from registry paths: " + ex.ToString());
            }
        }
        private void LoadPluginTypes(bool showErrors)
        {
            lock (_pluginTypesTable)
            {
                // reset existing contents
                _pluginTypesTable.Clear();

                PluginLoader pluginLoader = new PluginLoader(typeof(WriterPlugin).Assembly);

                //register the callbacks for each supported plugin type.
                foreach (Type pluginType in SupportedPluginTypes)
                {
                    //subscribe for a callback when a matching implementation type is found.
                    pluginLoader.AddPluginTypeCallback(pluginType, new PluginLoader.PluginLoadedCallback(RegisterPluginImpl));

                    //create a list to hold discovered plugin implementations.
                    _pluginTypesTable[pluginType] = new ArrayList();
                }

                // load from plugin directory
                if (PluginDirectory != null && Directory.Exists(PluginDirectory))
                    pluginLoader.LoadPluginsFromDirectory(PluginDirectory, showErrors);

                // load from plugins specified in the registry
                LoadPluginsFromRegistryPaths(pluginLoader, showErrors);

                // load from legacy plugin directory
                if (PluginDirectoryLegacy != null && Directory.Exists(PluginDirectoryLegacy))
                    pluginLoader.LoadPluginsFromDirectory(PluginDirectoryLegacy, showErrors);
            }

            // fire event
            if (PluginListChanged != null)
                PluginListChanged(this, EventArgs.Empty);
        }