Example #1
0
        public static void InstallAssembly(String path, InstallReference reference, bool force)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            AssemblyCommitFlags flags;

            if (force)
            {
                flags = AssemblyCommitFlags.ForceRefresh;
            }
            else
            {
                flags = AssemblyCommitFlags.Refresh;
            }

            FusionInstallReference fusionReference = null;

            if (reference != null)
            {
                if (!reference.CanBeUsed())
                {
                    throw new ArgumentException("InstallReferenceType can not be used", "reference");
                }

                fusionReference = new FusionInstallReference(reference.Type, reference.Identifier, reference.Description);
            }

            var assemblyCache = GetAssemblyCache();

            ComCheck(assemblyCache.InstallAssembly((int)flags, path, fusionReference));
        }
Example #2
0
        public static UninstallResult UninstallAssembly(AssemblyName assemblyName, InstallReference reference)
        {
            if (assemblyName == null)
            {
                throw new ArgumentNullException("assemblyName");
            }
            if (!assemblyName.IsFullyQualified())
            {
                throw new ArgumentOutOfRangeException("assemblyName", assemblyName, "Must be a fully qualified assembly name");
            }

            FusionInstallReference fusionReference = null;

            if (reference != null)
            {
                if (!reference.CanBeUsed())
                {
                    throw new ArgumentException("InstallReferenceType can not be used", "reference");
                }

                fusionReference = new FusionInstallReference(reference.Type, reference.Identifier, reference.Description);
            }

            var assemblyCache = GetAssemblyCache();

            AssemblyCacheUninstallDisposition disposition = AssemblyCacheUninstallDisposition.Uninstalled;

            ComCheck(assemblyCache.UninstallAssembly(0, assemblyName.GetFullyQualifiedName(), fusionReference, out disposition));

            return((UninstallResult)disposition);
        }