/// <summary> /// Searches for plugin types from assemblies in the application's startup path in a second AppDomain /// </summary> /// <param name="viewer"></param> /// <returns></returns> internal static TypeCollection SearchForPluginTypes(IProgressViewer progressViewer) { // create a new appdomain where we'll try and load the plugins AppDomain domain = AppDomain.CreateDomain(Guid.NewGuid().ToString()); // create an instance of the plugin loader in the new appdomain TypeLoader loader = (TypeLoader)domain.CreateInstanceFromAndUnwrap( Assembly.GetExecutingAssembly().Location, typeof(TypeLoader).FullName); // use the loader to search for plugins inside the second appdomain TypeCollection types = loader.InternalSearchForPluginTypes(progressViewer); // unload the appdomain AppDomain.Unload(domain); // return the plugin descriptors that were found return(types); }