} //ShowCreateForm

        private void ShowEditForm(object sender, EventArgs e)
        {
            SharePointVersion version = GetVersion("of the template to edit");

            if (version != SharePointVersion.SharePoint_Invalid)
            {
                EditWin editForm = new EditWin();

                editForm.FormClosed     += new FormClosedEventHandler(DestroyForm);
                editForm.Text            = "Edit Template - ";
                editForm.SelectedVersion = version;

                switch (version)
                {
                case SharePointVersion.SharePoint_2013_On_Premises:
                    editForm.Text += Constants.SharePoint_2013_On_Premises;
                    if (_sp2013OnPrem == null)
                    {
                        _sp2013OnPrem = Program.LoadSPLoader(version);
                    }

                    editForm.SharePointLoader = _sp2013OnPrem;

                    break;

                case SharePointVersion.SharePoint_2016_On_Premises:
                    editForm.Text += Constants.SharePoint_2016_On_Premises;
                    if (_sp2016OnPrem == null)
                    {
                        _sp2016OnPrem = Program.LoadSPLoader(version);
                    }

                    editForm.SharePointLoader = _sp2016OnPrem;

                    break;

                case SharePointVersion.SharePoint_2016_OnLine:
                    editForm.Text += Constants.SharePoint_2016_Online;
                    if (_sp2016Online == null)
                    {
                        _sp2016Online = Program.LoadSPLoader(version);
                    }

                    editForm.SharePointLoader = _sp2016Online;

                    break;

                default:
                    break;
                }

                editForm.OpenTemplate = OpenFile;

                editForm.SetStatusBarText = SetStatusBarText;

                editForm.MdiParent = this;

                editForm.Show();
            }
        } //ShowEditForm
        } //DestroyForm

        private string EnsureVersionLoaded(SharePointVersion version)
        {
            string spVersionTitle = string.Empty;

            switch (version)
            {
            case SharePointVersion.SharePoint_2013_On_Premises:
                spVersionTitle = Constants.SharePoint_2013_On_Premises;
                if (_sp2013OnPrem == null)
                {
                    _sp2013OnPrem = Program.LoadSPLoader(SharePointVersion.SharePoint_2013_On_Premises);
                }

                break;

            case SharePointVersion.SharePoint_2016_On_Premises:
                spVersionTitle = Constants.SharePoint_2016_On_Premises;
                if (_sp2016OnPrem == null)
                {
                    _sp2016OnPrem = Program.LoadSPLoader(SharePointVersion.SharePoint_2016_On_Premises);
                }

                break;

            case SharePointVersion.SharePoint_2016_OnLine:
                spVersionTitle = Constants.SharePoint_2016_Online;
                if (_sp2016Online == null)
                {
                    _sp2016Online = Program.LoadSPLoader(SharePointVersion.SharePoint_2016_OnLine);
                }

                break;

            default:
                break;
            }

            return(spVersionTitle);
        } //EnsureVersionLoaded
        public static SPLoader LoadSPLoader(SharePointVersion version)
        {
            SPLoader loader = null;

            switch (version)
            {
            case SharePointVersion.SharePoint_2013_On_Premises:

                AppDomainSetup setup2013OP = new AppDomainSetup()
                {
                    ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                    ApplicationName = NAME_SharePoint2013OnPrem,
                    PrivateBinPath  = $"{NAME_SharePoint2013OnPrem};",
                    DisallowApplicationBaseProbing = false,
                    DisallowBindingRedirects       = false
                };

                appDomain2013OP = AppDomain.CreateDomain(Constants.SharePoint_2013_On_Premises, null, setup2013OP);

                appDomain2013OP.Load(typeof(SPLoader).Assembly.FullName);

                loader = (SPLoader)Activator.CreateInstance(appDomain2013OP,
                                                            typeof(SPLoader).Assembly.FullName,
                                                            typeof(SPLoader).FullName,
                                                            false,
                                                            BindingFlags.Public | BindingFlags.Instance,
                                                            null, null, null, null).Unwrap();


                loader.LoadProvisioningAssembly(setup2013OP.ApplicationName);

                break;

            case SharePointVersion.SharePoint_2016_On_Premises:

                AppDomainSetup setup2016OP = new AppDomainSetup()
                {
                    ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                    ApplicationName = NAME_SharePoint2016OnPrem,
                    PrivateBinPath  = $"{NAME_SharePoint2016OnPrem};",
                    DisallowApplicationBaseProbing = false,
                    DisallowBindingRedirects       = false
                };

                appDomain2016OP = AppDomain.CreateDomain(Constants.SharePoint_2016_On_Premises, null, setup2016OP);

                appDomain2016OP.Load(typeof(SPLoader).Assembly.FullName);

                loader = (SPLoader)Activator.CreateInstance(appDomain2016OP,
                                                            typeof(SPLoader).Assembly.FullName,
                                                            typeof(SPLoader).FullName,
                                                            false,
                                                            BindingFlags.Public | BindingFlags.Instance,
                                                            null, null, null, null).Unwrap();


                loader.LoadProvisioningAssembly(setup2016OP.ApplicationName);

                break;

            case SharePointVersion.SharePoint_2016_OnLine:

                AppDomainSetup setup2016OL = new AppDomainSetup()
                {
                    ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                    ApplicationName = NAME_SharePoint2016Online,
                    PrivateBinPath  = $"{NAME_SharePoint2016Online};",
                    DisallowApplicationBaseProbing = false,
                    DisallowBindingRedirects       = false
                };

                appDomain2016OL = AppDomain.CreateDomain(Constants.SharePoint_2016_Online, null, setup2016OL);

                appDomain2016OL.Load(typeof(SPLoader).Assembly.FullName);

                loader = (SPLoader)Activator.CreateInstance(appDomain2016OL,
                                                            typeof(SPLoader).Assembly.FullName,
                                                            typeof(SPLoader).FullName,
                                                            false,
                                                            BindingFlags.Public | BindingFlags.Instance,
                                                            null, null, null, null).Unwrap();


                loader.LoadProvisioningAssembly(setup2016OL.ApplicationName);

                break;

            default:

                break;
            } //switch

            return(loader);
        } //LoadSPLoader