Ejemplo n.º 1
0
        public static void InstallAssembly(String assemblyPath, FUSION_INSTALL_REFERENCE reference, AssemblyCommitFlags flags)
        {
            if (reference != null)
            {
                if (!InstallReferenceGuid.IsValidInstallGuidScheme(reference.GuidScheme))
                    throw new ArgumentException("Invalid reference guid.", "guid");
            }

            IAssemblyCache ac = null;

            int hr = 0;

            hr = FusionImports.CreateAssemblyCache(out ac, 0);
            if (hr >= 0)
            {
                hr = ac.InstallAssembly((int)flags, assemblyPath, reference);
            }

            if (hr < 0)
            {
                if (hr == -2146234300 /*0x80131044*/)
                    throw new AssemblyMustBeStronglyNamedException();
                else
                    Marshal.ThrowExceptionForHR(hr);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Installs an assembly into the GAC. Adds a reference to the installing applicaiton.
        /// </summary>
        /// <param name="assemblyPath">The path to the assembly to be installed</param>
        /// <param name="flags">see AssemblyCommitFlags</param>
        internal static void InstallAssembly(String assemblyPath, AssemblyCommitFlags flags)
        {
            IAssemblyCache ac = null;
            int            hr = 0;

            hr = GacUtils.CreateAssemblyCache(out ac, 0);
            if (hr >= 0)
            {
                hr = ac.InstallAssembly((int)flags, assemblyPath, null);
            }
            if (hr < 0)
            {
                GacUtils.ThrowMarshalledException(hr);
            }
        }
Ejemplo n.º 3
0
        private void InstallAssembly(string assemblyPath, InstallReference reference, bool force)
        {
            if (reference != null && !InstallReferenceGuid.IsValidGuidScheme(reference.GuidScheme))
            {
                throw new ArgumentException("Invalid reference guid.", "reference");
            }
            AssemblyCommitFlags assemblyCommitFlags = force ? AssemblyCommitFlags.Force : AssemblyCommitFlags.Default;
            IAssemblyCache      ppAsmCache;
            int assemblyCache = NativeMethods.CreateAssemblyCache(out ppAsmCache, 0);

            Marshal.ThrowExceptionForHR(assemblyCache);
            if (assemblyCache < 0)
            {
                return;
            }
            Marshal.ThrowExceptionForHR(ppAsmCache.InstallAssembly((int)assemblyCommitFlags, assemblyPath, reference));
        }
Ejemplo n.º 4
0
        public static void InstallAssembly(String assemblyPath, InstallReference reference, AssemblyCommitFlags flags)
        {
            if (reference != null) {
                if (!InstallReferenceGuid.IsValidGuidScheme(reference.GuidScheme))
                    throw new ArgumentException("Invalid reference guid.", "guid");
            }

            IAssemblyCache ac = null;

            int hr = 0;

            hr = Utils.CreateAssemblyCache(out ac, 0);
            if (hr >= 0) {
                hr = ac.InstallAssembly((int)flags, assemblyPath, reference);
            }

            if (hr < 0) {
                Marshal.ThrowExceptionForHR(hr);
            }
        }
Ejemplo n.º 5
0
        public static void InstallAssembly(String assemblyPath, InstallReference reference, AssemblyCommitFlags flags, GACVersion gacVersion = GACVersion.Net40)
        {
            if (reference != null) {
                if (!InstallReferenceGuid.IsValidGuidScheme(reference.GuidScheme)) {
                    throw new ArgumentException("Invalid reference guid.", "guid");
                }
            }

            IAssemblyCache ac = null;

            int hr = 0;

            switch (gacVersion) {
                case GACVersion.Net40:
                    hr = Utils.CreateAssemblyCache40(out ac, 0);
                    break;
                case GACVersion.Net20:
                    hr = Utils.CreateAssemblyCache20(out ac, 0);
                    break;
            }
            // hr = Utils.CreateAssemblyCache(out ac, 0);
            if (hr >= 0) {
                hr = ac.InstallAssembly((int)flags, assemblyPath, reference);
            }

            if (hr < 0) {
                Marshal.ThrowExceptionForHR(hr);
            }
        }
Ejemplo n.º 6
0
        public static void InstallAssembly(String assemblyPath, InstallReference reference, AssemblyCommitFlags flags)
        {
            if (reference != null)
            {
                if (!InstallReferenceGuid.IsValidGuidScheme(reference.GuidScheme))
                {
                    throw new ArgumentException("Invalid reference guid.", "guid");
                }
            }

            IAssemblyCache ac = null;

            int hr = 0;

            hr = Utils.CreateAssemblyCache(out ac, 0);
            if (hr >= 0)
            {
                hr = ac.InstallAssembly((int)flags, assemblyPath, reference);
            }

            if (hr < 0)
            {
                Marshal.ThrowExceptionForHR(hr);
            }
        }
Ejemplo n.º 7
0
        public static void InstallAssembly(String assemblyPath, FUSION_INSTALL_REFERENCE reference, AssemblyCommitFlags flags)
        {
            if (reference != null)
            {
                if (!InstallReferenceGuid.IsValidInstallGuidScheme(reference.GuidScheme))
                {
                    throw new ArgumentException("Invalid reference guid.", "guid");
                }
            }

            IAssemblyCache ac = null;

            int hr = 0;

            hr = FusionImports.CreateAssemblyCache(out ac, 0);
            if (hr >= 0)
            {
                hr = ac.InstallAssembly((int)flags, assemblyPath, reference);
            }

            if (hr < 0)
            {
                if (hr == -2146234300 /*0x80131044*/)
                {
                    throw new AssemblyMustBeStronglyNamedException();
                }
                else
                {
                    Marshal.ThrowExceptionForHR(hr);
                }
            }
        }
        // If you use this, fusion will do the streaming & commit
        public static void InstallAssembly(string assemblyPath, InstallReference reference, AssemblyCommitFlags flags)
        {
            if (reference != null)
            {
                if (!InstallReferenceGuid.IsValidGuidScheme(reference.GuidScheme))
                    throw new ArgumentException("Invalid argument( reference guid).");
            }

            IAssemblyCache asmCache = null;

            COM.CheckHR(CreateAssemblyCache(out asmCache, 0));
            COM.CheckHR(asmCache.InstallAssembly((int) flags, assemblyPath, reference));
        }
Ejemplo n.º 9
0
        // If you use this, fusion will do the streaming & commit
        public static void InstallAssembly(string assemblyPath, InstallReference reference, AssemblyCommitFlags flags)
        {
            if (reference != null)
            {
                if (!InstallReferenceGuid.IsValidGuidScheme(reference.GuidScheme))
                {
                    throw new ArgumentException("Invalid argument( reference guid).");
                }
            }

            IAssemblyCache asmCache = null;

            COM.CheckHR(CreateAssemblyCache(out asmCache, 0));
            COM.CheckHR(asmCache.InstallAssembly((int)flags, assemblyPath, reference));
        }