public static void CheckIfInstallable(string assemblyName)
 {
     AssemblyInstaller installer = new AssemblyInstaller {
         UseNewContext = false,
         Path = assemblyName,
         CommandLine = new string[0],
         Context = new InstallContext(null, new string[0])
     };
     installer.InitializeFromAssembly();
     if (installer.Installers.Count == 0)
     {
         throw new InvalidOperationException(System.Configuration.Install.Res.GetString("InstallNoPublicInstallers", new object[] { assemblyName }));
     }
 }
        /// <summary>Checks to see if the specified assembly can be installed.</summary>
        /// <param name="assemblyName">The assembly in which to search for installers. </param>
        /// <exception cref="T:System.Exception">The specified assembly cannot be installed. </exception>
        public static void CheckIfInstallable(string assemblyName)
        {
            var assemblyInstaller = new AssemblyInstaller();

            assemblyInstaller.UseNewContext = false;
            assemblyInstaller.Path          = assemblyName;
            assemblyInstaller.CommandLine   = new string[0];
            assemblyInstaller.Context       = new InstallContext(null, new string[0]);
            assemblyInstaller.InitializeFromAssembly();
            if (assemblyInstaller.Installers.Count == 0)
            {
                throw new InvalidOperationException(Res.GetString("InstallNoPublicInstallers", assemblyName));
            }
        }
Пример #3
0
        public static void CheckIfInstallable(string assemblyName)
        {
            AssemblyInstaller installer = new AssemblyInstaller {
                UseNewContext = false,
                Path          = assemblyName,
                CommandLine   = new string[0],
                Context       = new InstallContext(null, new string[0])
            };

            installer.InitializeFromAssembly();
            if (installer.Installers.Count == 0)
            {
                throw new InvalidOperationException(System.Configuration.Install.Res.GetString("InstallNoPublicInstallers", new object[] { assemblyName }));
            }
        }
        /// <include file='doc\AssemblyInstaller.uex' path='docs/doc[@for="AssemblyInstaller.CheckIfInstallable"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Finds the installers in the specified assembly, creates
        ///       a new instance of <see cref='System.Configuration.Install.AssemblyInstaller'/>
        ///       , and adds the installers to its installer collection.
        ///    </para>
        /// </devdoc>
        public static void CheckIfInstallable(string assemblyName)
        {
            AssemblyInstaller tester = new AssemblyInstaller();

            tester.UseNewContext = false;
            tester.Path          = assemblyName;
            tester.CommandLine   = new string[0];
            tester.Context       = new InstallContext(null, new string[0]);

            // this does the actual check and throws if necessary.
            tester.InitializeFromAssembly();
            if (tester.Installers.Count == 0)
            {
                throw new InvalidOperationException(Res.GetString(Res.InstallNoPublicInstallers, assemblyName));
            }
        }