Ejemplo n.º 1
0
        public override void Install(IDictionary stateSaver)
        {
            try
            {
                SecurityPermission permission =
                    new SecurityPermission(PermissionState.Unrestricted);
                permission.Demand();
            }
            catch (SecurityException)
            {
                throw new InstallException(
                          "You have insufficient privileges to " +
                          "register a trust relationship. Start Excel " +
                          "and confirm the trust dialog to run the addin.");
            }
            Uri deploymentManifestLocation = null;

            if (Uri.TryCreate(Context.Parameters["deploymentManifestLocation"],
                              UriKind.RelativeOrAbsolute, out deploymentManifestLocation) == false)
            {
                throw new InstallException(
                          "The location of the deployment manifest is missing or invalid.");
            }
            AddInSecurityEntry entry = new AddInSecurityEntry(
                deploymentManifestLocation, RSA_PublicKey);

            UserInclusionList.Add(entry);
            stateSaver.Add("entryKey", deploymentManifestLocation);
            base.Install(stateSaver);
        }
Ejemplo n.º 2
0
        public override void Uninstall(IDictionary savedState)
        {
            Uri deploymentManifestLocation = (Uri)savedState["entryKey"];

            if (deploymentManifestLocation != null)
            {
                UserInclusionList.Remove(deploymentManifestLocation);
            }
            base.Uninstall(savedState);
        }