Exemplo n.º 1
0
        /// <summary>
        /// Installs a SharpShell server at the specified path via RegAsm.
        /// </summary>
        /// <param name="path">The path to the SharpShell server.</param>
        /// <param name="registrationType">Type of the registration.</param>
        /// <param name="codeBase">if set to <c>true</c> install from codebase rather than GAC.</param>
        private void InstallServerViaRegAsm(string path, RegistrationType registrationType, bool codeBase)
        {
            //  Validate the path.
            if (string.IsNullOrWhiteSpace(path) || File.Exists(path) == false)
            {
                outputService.WriteError("File '" + path + "' does not exist.", true);
                return;
            }

            var regAsm = new RegAsm();

            var success =
                registrationType == RegistrationType.OS32Bit
                    ? regAsm.Register32(path, codeBase)
                    : regAsm.Register64(path, codeBase);

            if (success)
            {
                outputService.WriteSuccess($"    {path} installed and registered.", true);
                outputService.WriteMessage(regAsm.StandardOutput);
            }
            else
            {
                outputService.WriteError($"    {path} failed to register.", true);
                outputService.WriteError(regAsm.StandardError);
            }
        }
Exemplo n.º 2
0
        private void installToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //  Bail if we have no server selected.
            if (SelectedServerEntry == null)
            {
                return;
            }

            //  Create a regasm instance and register the server.
            var regasm  = new RegAsm();
            var success = Environment.Is64BitOperatingSystem ? regasm.Register64(SelectedServerEntry.ServerPath, true) : regasm.Register32(SelectedServerEntry.ServerPath, true);

            //  Inform the user of the result.
            if (success)
            {
                MessageBox.Show(@"Installed server successfully.", @"Install Server", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(@"Failed to install, check the SharpShell log for details.", @"Install Server", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }