Пример #1
0
        /// <summary>
        /// Install the IIS samples.
        /// </summary>
        /// <param name="stateSaver"></param>
        /// <remarks>
        /// 1. check for Default Web Site
        /// 2. create AppPool named "PhalangerAppPool" (if not yet)
        /// 3. create application "Default Web Site"/"Phalanger..." using AppPool "PhalangerAppPool"
        /// </remarks>
        public override void Install(IDictionary stateSaver)
        {
            try
            {
                IIS.CreateApplicationPool(
                    PhalangerAppPool,
                    Microsoft.Web.Administration.ProcessModelIdentityType.ApplicationPoolIdentity, null, null,  // IIS defaults
                    ManagedRuntimeVersion, true,
                    true, // enable 32bit 
                    Microsoft.Web.Administration.ManagedPipelineMode.Integrated,
                    1000, new TimeSpan(0, 20, 0), 0, new TimeSpan(0, 0, 0)  // IIS defaults
                    );
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                ShowError("IIS 7 is not installed properly. The installation cannot continue.");
                throw;
            }
            catch (Exception ex)
            {
                ShowError("Unable to create '{0}' IIS application pool\n\n{1}\n{2}", PhalangerAppPool, ex.Message, ex.GetType());
            }

            foreach (var sample in Samples)
            {
                try
                {
                    IIS.AddApplication(DefaultWebSite, ApplicationDir(sample), PhalangerAppPool, WebSamplesDir + '\\' + sample, null, null);
                }
                catch (System.Runtime.InteropServices.COMException)
                {
                    ShowError("IIS 7 is not installed properly. The installation cannot continue.");
                    throw;
                }
                catch (Exception ex)
                {
                    ShowError("Unable to create '{0}' IIS application in '{1}'\n\n{2}", sample, DefaultWebSite, ex.Message);
                }
            }
        }
Пример #2
0
        public override void Uninstall(IDictionary savedState)
        {
            foreach (var sample in Samples)
            {
                try
                {
                    IIS.RemoveApplication(DefaultWebSite, ApplicationDir(sample));
                }
                catch (Exception ex)
                {
                    ShowError("Error while removing '{0}' IIS applications from '{1}'\n\n{2}", sample, DefaultWebSite, ex.Message);
                }
            }

            try
            {
                IIS.RemoveApplicationPool(PhalangerAppPool);
            }
            catch (Exception ex)
            {
                ShowError("Error while removing '{0}' IIS application pool\n\n{1}", PhalangerAppPool, ex.Message);
            }
        }