Exemple #1
0
        /// <summary>
        /// Harvest the registry values written by RegisterTypeLib.
        /// </summary>
        /// <param name="path">The file to harvest registry values from.</param>
        /// <returns>The harvested registry values.</returns>
        public Wix.RegistryValue[] HarvestRegistryValues(string path)
        {
            using (RegistryHarvester registryHarvester = new RegistryHarvester(true))
            {
                NativeMethods.RegisterTypeLibrary(path);

                return(registryHarvester.HarvestRegistry());
            }
        }
Exemple #2
0
        /// <summary>
        /// Harvest the registry values written by RegisterAssembly.
        /// </summary>
        /// <param name="path">The file to harvest registry values from.</param>
        /// <returns>The harvested registry values.</returns>
        public Wix.RegistryValue[] HarvestRegistryValues(string path)
        {
            RegistrationServices regSvcs  = new RegistrationServices();
            Assembly             assembly = Assembly.LoadFrom(path);

            // must call this before overriding registry hives to prevent binding failures
            // on exported types during RegisterAssembly
            assembly.GetExportedTypes();

            using (RegistryHarvester registryHarvester = new RegistryHarvester(true))
            {
                regSvcs.RegisterAssembly(assembly, AssemblyRegistrationFlags.SetCodeBase);

                return(registryHarvester.HarvestRegistry());
            }
        }
        /// <summary>
        /// Harvest the registry values written by calling DllRegisterServer on the specified file.
        /// </summary>
        /// <param name="file">The file to harvest registry values from.</param>
        /// <returns>The harvested registry values.</returns>
        public Wix.RegistryValue[] HarvestRegistryValues(string file)
        {
            // load the DLL
            NativeMethods.LoadLibrary(file);

            using (RegistryHarvester registryHarvester = new RegistryHarvester(true))
            {
                try
                {
                    DynamicPInvoke(file, "DllRegisterServer", typeof(int), null, null);

                    return(registryHarvester.HarvestRegistry());
                }
                catch (TargetInvocationException e)
                {
                    e.Data["file"] = file;
                    throw;
                }
            }
        }