public static string[] SelectTypes()
        {
            AppDomainSetup ads = new AppDomainSetup();

            ads.ApplicationBase =
                "file:///" + AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            ads.DisallowBindingRedirects = false;
            ads.DisallowCodeDownload     = true;
            ads.ConfigurationFile        = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
            //
            // Create the second AppDomain.
            AppDomain ad2 = AppDomain.CreateDomain("LimnorStudioSelectTypes", null, ads);

            ad2.DomainUnload += new EventHandler(ad2_DomainUnload);
            TypeImporter obj = (TypeImporter)ad2.CreateInstanceAndUnwrap(
                typeof(TypeImporter).Assembly.FullName,
                typeof(TypeImporter).FullName
                );

            obj.Run();
            try
            {
                string[] ret = obj.SelectedTypes;
                return(ret);
            }
            catch
            {
                return(null);
            }
            finally
            {
                AppDomain.Unload(ad2);
            }
        }
 void miAdd_Click(object sender, EventArgs e)
 {
     if (toolbox != null && itemList != null)
     {
         string[] saTypes = TypeImporter.SelectTypes();
         if (saTypes != null && saTypes.Length > 0)
         {
             for (int i = 0; i < saTypes.Length; i++)
             {
                 Type tp = Type.GetType(saTypes[i]);
                 if (tp != null)
                 {
                     xToolboxItem x;
                     x = new xToolboxItem(tp);
                     itemList.Items.Add(x);
                 }
                 else
                 {
                     MessageBox.Show(FindForm(), string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                                               "Cannot load {0}", saTypes[i]), "Load types", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             AdjustSize();
             toolbox.Changed = true;
             toolbox.AdjustTabPos(this.Index - 1);
         }
     }
 }