Inheritance: IRegistrationServices
Exemplo n.º 1
0
 /// <summary>
 /// When overridden in a derived class, performs the installation.
 /// </summary>
 /// <param name="stateSaver">An <see cref="T:System.Collections.IDictionary"/> used to save information needed to perform a commit, rollback, or uninstall operation.</param>
 public override void Install(IDictionary stateSaver)
 {
     base.Install(stateSaver);
     RegistrationServices regServices = new RegistrationServices();
     if (!regServices.RegisterAssembly(GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase))
         throw new InstallException("Error during registration of " + GetType().Assembly.FullName);
 }
Exemplo n.º 2
0
        public override void Install(IDictionary stateSaver)
        {

            new System.EnterpriseServices.Internal.Publish().GacInstall("WMIKatz.dll");
            base.Install(stateSaver);
            System.Runtime.InteropServices.RegistrationServices RS = new System.Runtime.InteropServices.RegistrationServices();
        }
		public static void UnregisterSelf()
		{
			RegistrationServices aRS = new RegistrationServices();
			Assembly thisAssembly = Assembly.GetExecutingAssembly();
			if (thisAssembly != null)
				aRS.UnregisterAssembly(thisAssembly);
		}
        static void Main(string[] args)
        {
            Debug.WriteLine("M:{0}/U:{1} - Main()", Thread.CurrentThread.ManagedThreadId, PInvoke.GetCurrentThreadId());

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //if (args.Length > 0)
            //    MessageBox.Show(args[0]);

            if (args.Length == 1 && args[0] == "-Embedding")
            {
                MessageBox.Show(args[0]);
                return;
            }

            RegistrationServices rs = new RegistrationServices();
            int cookie = rs.RegisterTypeForComClients(typeof(Class1), RegistrationClassContext.LocalServer, RegistrationConnectionType.MultipleUse);

            try
            {
                Application.Run(new Form1());
            }
            catch
            {
            }

            rs.UnregisterTypeForComClients(cookie);
        }
        public static void Install()
        {
            Assembly objAssembly = Assembly.GetExecutingAssembly();
            RegistrationServices objRegServices = new RegistrationServices();

            try
            {
                objRegServices.RegisterAssembly(objAssembly, AssemblyRegistrationFlags.SetCodeBase);

                RegistryKey objRK = Registry.CurrentUser.OpenSubKey(PATH_EXPLORER, true);
                objRK.SetValue("DesktopProcess", 1);
                objRK.Close();

                objRK = Registry.LocalMachine.OpenSubKey(PATH_APPROVED, true);
                objRK.SetValue(BuildHandler.CLSID, "RBuild");
                objRK.Close();

                objRK = Registry.ClassesRoot.CreateSubKey(PATH_RBUILD);
                objRK.SetValue(string.Empty, BuildHandler.CLSID);
                objRK.Close();
            }//try
            catch (Exception Ex)
            {
                Console.WriteLine(Ex.Message);
            }//catch
        }
Exemplo n.º 6
0
        /// <summary>
        /// Deinstallation
        /// </summary>
        /// <param name="savedState"></param>
        public override void Uninstall(System.Collections.IDictionary savedState)
        {
            base.Uninstall(savedState);

            Assembly asm = Assembly.GetExecutingAssembly();

            string fullName = asm.GetModules()[0].FullyQualifiedName;
            string dataFolder = Toolbar.AppFolder;

            //try
            //{
            //    Directory.Delete(dataFolder, true);
            //}
            //catch (Exception)
            //{
            //    throw new InstallException("Failed to delete folder");
            //}

            //try
            //{
            //    Registry.LocalMachine.DeleteSubKeyTree(IEToolbarEngine.AppKey);
            //    Registry.CurrentUser.DeleteSubKeyTree(IEToolbarEngine.AppKey);
            //}
            //catch (Exception)
            //{
            //}

            RegistrationServices regsrv = new RegistrationServices();

            if (!regsrv.UnregisterAssembly(this.GetType().Assembly))
            {
                throw new InstallException("Failed To Unregister for COM");
            }
        }
Exemplo n.º 7
0
Arquivo: Program.cs Projeto: tmbx/Ted
        static void Main(string[] args)
        {
            bool unregisterMode = false;
            bool debugMode = false;
            List<string> dllList = new List<string>();

            if (args.Length == 0)
            {
                Console.Error.WriteLine("Ted has nothing to do. Press any key.");
                Console.ReadLine();
                Environment.Exit(1);
            }

            // Make sure all file exists.
            foreach (string dll in args)
            {
                // This is the unregister mode switch.
                if (dll.Equals("-u"))
                {
                    unregisterMode = true;
                    continue;
                }
                // This is the debug mode switch.
                if (dll.Equals("-d"))
                {
                    debugMode = true;
                    continue;
                }

                // Make sure each file we are going to register exists.
                if (File.Exists(dll)) dllList.Add(dll);
                else
                {
                    Console.Error.WriteLine("Error: File " + dll + " does not exists. Press any key.");
                    Console.ReadLine();
                    Environment.Exit(1);
                }
            }

            // Iterate over all DLLs and register each of them.
            foreach (string dll in dllList)
            {
                try
                {
                    string dllFullPath = Path.GetFullPath(dll);
                    Assembly assemblyDll = Assembly.LoadFile(dllFullPath);
                    RegistrationServices regSrv = new RegistrationServices();

                    if (!unregisterMode)
                        regSrv.RegisterAssembly(assemblyDll, AssemblyRegistrationFlags.SetCodeBase);
                    else
                        regSrv.UnregisterAssembly(assemblyDll);
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("Error registering " + dll + ".");
                    if (debugMode) Console.Error.WriteLine(ex);
                }
            }
        }
Exemplo n.º 8
0
 public override void Install(System.Collections.IDictionary stateSaver)
 {
     base.Install(stateSaver);
     RegistrationServices regSrv = new RegistrationServices();
     regSrv.RegisterAssembly(base.GetType().Assembly,
         AssemblyRegistrationFlags.SetCodeBase);
 }
Exemplo n.º 9
0
        public override void Uninstall(IDictionary savedState)
        {
            base.Uninstall(savedState);

            Assembly asm = Assembly.GetExecutingAssembly();
            RegistrationServices reg = new RegistrationServices();
            reg.UnregisterAssembly(asm);
        }
Exemplo n.º 10
0
 public override void Uninstall(System.Collections.IDictionary savedState)
 {
     base.Uninstall(savedState);
     RegistrationServices regsrv = new RegistrationServices();
     if (!regsrv.UnregisterAssembly(this.GetType().Assembly))
     {
         throw new InstallException("libron�c�[���o�[�̓o�^����Ɏ��s���܂���");
     }
 }
Exemplo n.º 11
0
		public static void RegisterServer( Assembly assemblyToRegister )
		{
			if ( ComRegister != null )
			{
				RegistrationServices reg = new RegistrationServices();
				reg.RegisterAssembly( assemblyToRegister, AssemblyRegistrationFlags.SetCodeBase );
				ComRegister();
			}
		}
Exemplo n.º 12
0
        public override void Install(IDictionary stateSaver)
        {
            base.Install(stateSaver);

            // Call RegistrationServices.RegisterAssembly to register the classes in 
            // the current managed assembly to enable creation from COM.
            var regService = new RegistrationServices();
            regService.RegisterAssembly(GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase);
        }
Exemplo n.º 13
0
		public static void UnregisterServer( Assembly assemblyToRegister )
		{
			if ( ComUnregister != null )
			{
				RegistrationServices reg = new RegistrationServices();
				reg.UnregisterAssembly( assemblyToRegister );
				ComUnregister();
			}
		}
Exemplo n.º 14
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="stateSaver"></param>
 public override void Install(System.Collections.IDictionary stateSaver)
 {
     base.Install(stateSaver);
     RegistrationServices regsrv = new RegistrationServices();
     if (!regsrv.RegisterAssembly(this.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase))
     {
         throw new InstallException("Failed To Register for COM Interop");
     }
 }
        public static void Initialize()
        {
            regService = new RegistrationServices();

            cookie = regService.RegisterTypeForComClients(
                typeof(NotificationActivator),
                RegistrationClassContext.LocalServer,
                RegistrationConnectionType.MultipleUse);
        }
Exemplo n.º 16
0
		public static void Register()
		{
			try
			{
				RegistrationServices svc = new RegistrationServices();
				svc.RegisterAssembly(typeof (Program).Assembly, AssemblyRegistrationFlags.SetCodeBase);
			}
			catch (Exception e) { throw new ApplicationException(e.Message, e); }
		}
Exemplo n.º 17
0
        public override void Uninstall(IDictionary savedState)
        {
            base.Uninstall(savedState);

            // Call RegistrationServices.UnregisterAssembly to unregister the classes 
            // in the current managed assembly.
            RegistrationServices regService = new RegistrationServices();
            regService.UnregisterAssembly(this.GetType().Assembly);
        }
Exemplo n.º 18
0
        public void DLLRegisterServer(int regMode)
        {
            //register dll 
            //same as:
            //post build event: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe $(TargetPath) /codebase

            RegistrationServices regAsm = new RegistrationServices();
            bool bResult = regAsm.RegisterAssembly(ComponentConfig.typeToRegister.Assembly, AssemblyRegistrationFlags.SetCodeBase);
        }
Exemplo n.º 19
0
 public override void Uninstall(System.Collections.IDictionary savedState)
 {
     base.Uninstall(savedState);
     RegistrationServices regsrv = new RegistrationServices();
     if (!regsrv.UnregisterAssembly(this.GetType().Assembly))
     {
         throw new InstallException("libronツールバーの登録解除に失敗しました");
     }
 }
Exemplo n.º 20
0
 /// <summary>
 /// This is called when installer's custom action executes and
 /// registers the toolbar which is extending a bandobject, as COM server.
 /// </summary>
 /// <param name="stateSaver"></param>     
 public override void Uninstall(System.Collections.IDictionary savedState)
 {
     base.Uninstall(savedState);
     RegistrationServices regsrv = new RegistrationServices();
     if (!regsrv.UnregisterAssembly(this.GetType().Assembly))
     {
         throw new InstallException("Failed To Unregister for COM");
     }
 }
Exemplo n.º 21
0
 public override void Install(System.Collections.IDictionary stateSaver)
 {
     System.Windows.Forms.MessageBox.Show("��ʼִ�а�װ���Զ������...");
     base.Install(stateSaver);
     RegistrationServices regsrv = new RegistrationServices();
     if (!regsrv.RegisterAssembly(this.GetType().Assembly,AssemblyRegistrationFlags.SetCodeBase))
     {
         throw new InstallException("Failed To Register for COM");
     }
 }
Exemplo n.º 22
0
 public override void Install(System.Collections.IDictionary stateSaver)
 {
     base.Install(stateSaver);
     RegistrationServices regsrv = new RegistrationServices();
     if (!regsrv.RegisterAssembly(this.GetType().Assembly,
     AssemblyRegistrationFlags.SetCodeBase))
     {
         throw new InstallException("Libronツールバーの登録に失敗しました");
     }
 }
Exemplo n.º 23
0
        public override void Uninstall(System.Collections.IDictionary savedState)
        {
            System.Windows.Forms.MessageBox.Show("��ʼִ��uninstall���Զ������...");

            base.Uninstall(savedState);
            RegistrationServices regsrv = new RegistrationServices();
            if (!regsrv.UnregisterAssembly(this.GetType().Assembly))
            {
                throw new InstallException("Failed To Unregister for COM");
            }
        }
Exemplo n.º 24
0
        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);

            RegistrationServices regsrv = new System.Runtime.InteropServices.RegistrationServices();

            if (!regsrv.RegisterAssembly(this.GetType().Assembly, System.Runtime.InteropServices.AssemblyRegistrationFlags.SetCodeBase))
            {
                throw new System.Exception("Failed to register object");
            }
        }
Exemplo n.º 25
0
		/// <summary>
		/// Register the assembly for COM interop
		/// </summary>
		/// <param name="stateSaver">An IDictionary used to save information 
		/// needed to perform a commit, rollback, or uninstall operation.
		/// </param>
		public override void Install(IDictionary stateSaver)
		{
			base.Install (stateSaver);

			RegistrationServices regSrv = new RegistrationServices();

			System.Reflection.Assembly assembly = base.GetType().Assembly;

			AssemblyRegistrationFlags flags = AssemblyRegistrationFlags.SetCodeBase;

			regSrv.RegisterAssembly(assembly, flags);
		}
Exemplo n.º 26
0
 /// <summary>
 /// Custom Install Action that performs custom registration steps as well as
 /// registering for COM Interop.
 /// </summary>
 /// <param name="stateSaver">Not used<see cref="Installer"/></param>
 public override void Install(System.Collections.IDictionary stateSaver)
 {
     Trace.WriteLine("Install custom action - Starting registration for COM Interop");
     base.Install(stateSaver);
     RegistrationServices regsrv = new RegistrationServices();
     if (!regsrv.RegisterAssembly(this.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase))
     {
         Trace.WriteLine("COM registration failed");
         throw new InstallException("Failed To Register for COM Interop");
     }
     Trace.WriteLine("Completed registration for COM Interop");
 }
Exemplo n.º 27
0
 private void EnsureManagedCategoryExists()
 {
     if (RegistrationServices.ManagedCategoryExists())
     {
         return;
     }
     using (RegistryKey subKey1 = Registry.ClassesRoot.CreateSubKey("Component Categories"))
     {
         using (RegistryKey subKey2 = subKey1.CreateSubKey("{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}"))
             subKey2.SetValue("0", (object)".NET Category");
     }
 }
Exemplo n.º 28
0
		public void UnRegister()
		{
			Assembly[] assemblies = m_regData.GetAssemblies();
			RegistrationServices regServ = new RegistrationServices();
			foreach( Assembly assembly in assemblies )
			{
				Write( "Registering .NET/COM Components: "+assembly.Location+"..." );
				bool success = regServ.UnregisterAssembly(assembly);
				WriteLine( success ? "Done." : "COM unregistration failed." );
			}
			Write("Disconnecting registered components from Microsoft Office...");
		}
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            //System.Console.Out.WriteLine("arguments: "+args.Length);

            try
            {
                if (args.Length == 2)
                {
                    Publish p = new Publish();
                    if (args[0] == "install")
                    {
                        System.Console.Out.WriteLine("Registering {0} into GAC", args[1]);
                        p.GacInstall(args[1]);
                    }
                    else if (args[0] == "remove")
                    {
                        System.Console.Out.WriteLine("Removing {0} from GAC", args[1]);
                        p.GacRemove(args[1]);
                    }
                    else if (args[0] == "installasm")
                    {
                        System.Console.Out.WriteLine("Registering Assembly {0}", args[1]);
                        RegistrationServices regsrv = new System.Runtime.InteropServices.RegistrationServices();
                        Assembly ass = Assembly.LoadFrom(args[1]);
                        regsrv.RegisterAssembly( ass,
                            System.Runtime.InteropServices.AssemblyRegistrationFlags.SetCodeBase);
                        //p.RegisterAssembly(args[1]);
                    }
                    else if (args[0] == "removeasm")
                    {
                        System.Console.Out.WriteLine("Removing Assembly {0}", args[1]);
                        RegistrationServices regsrv = new System.Runtime.InteropServices.RegistrationServices();
                        Assembly ass = Assembly.LoadFrom(args[1]);
                        regsrv.UnregisterAssembly( ass );
                        //p.UnRegisterAssembly(args[1]);
                    }
                    else
                    {
                        displayUsage();
                    }
                }
                else
                {
                    displayUsage();
                }
            }
            catch (Exception E) {
                String s = "Error "+E.Source+" while "+args[0]+" "+args[1]+": "+E.Message;
                s = DateTime.Now.ToString()+" "+s;
                System.Console.Out.WriteLine(s);
            }
        }
Exemplo n.º 30
0
        static void Main(string[] args)
        {
            //System.Console.Out.WriteLine("arguments: "+args.Length);

            try
            {
                if (args.Length == 2)
                {
                    Publish p = new Publish();
                    if (args[0] == "install")
                    {
                        System.Console.Out.WriteLine("Registering {0} into GAC", args[1]);
                        p.GacInstall(args[1]);
                    }
                    else if (args[0] == "remove")
                    {
                        System.Console.Out.WriteLine("Removing {0} from GAC", args[1]);
                        p.GacRemove(args[1]);
                    }
                    else if (args[0] == "installasm")
                    {
                        System.Console.Out.WriteLine("Registering Assembly {0}", args[1]);
                        RegistrationServices regsrv = new System.Runtime.InteropServices.RegistrationServices();
                        Assembly             ass    = Assembly.LoadFrom(args[1]);
                        regsrv.RegisterAssembly(ass,
                                                System.Runtime.InteropServices.AssemblyRegistrationFlags.SetCodeBase);
                        //p.RegisterAssembly(args[1]);
                    }
                    else if (args[0] == "removeasm")
                    {
                        System.Console.Out.WriteLine("Removing Assembly {0}", args[1]);
                        RegistrationServices regsrv = new System.Runtime.InteropServices.RegistrationServices();
                        Assembly             ass    = Assembly.LoadFrom(args[1]);
                        regsrv.UnregisterAssembly(ass);
                        //p.UnRegisterAssembly(args[1]);
                    }
                    else
                    {
                        displayUsage();
                    }
                }
                else
                {
                    displayUsage();
                }
            }
            catch (Exception E) {
                String s = "Error " + E.Source + " while " + args[0] + " " + args[1] + ": " + E.Message;
                s = DateTime.Now.ToString() + " " + s;
                System.Console.Out.WriteLine(s);
            }
        }
Exemplo n.º 31
0
        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install (stateSaver);

            RegistrationServices regsrv = new System.Runtime.InteropServices.RegistrationServices();

            if(!regsrv.RegisterAssembly(this.GetType().Assembly,System.Runtime.InteropServices.AssemblyRegistrationFlags.SetCodeBase))
            {

                throw new System.Exception("Failed to register object");

            }
        }
Exemplo n.º 32
0
 /// <summary>
 /// When overridden in a derived class, restores the pre-installation state of the computer.
 /// </summary>
 /// <param name="savedState">An <see cref="T:System.Collections.IDictionary"/> that contains the pre-installation state of the computer.</param>
 public override void Rollback(IDictionary savedState)
 {
     try
     {
         RegistrationServices regServices = new RegistrationServices();
         regServices.UnregisterAssembly(GetType().Assembly);
     }
     catch (Exception) { }
     finally
     {
         base.Rollback(savedState);
     }
 }
        public override void Uninstall(IDictionary savedState)
        {
            base.Uninstall(savedState);

            Assembly regAssembly = base.GetType().Assembly;
            string tlbPath = Path.Combine(Path.GetDirectoryName(regAssembly.Location),
                Path.GetFileNameWithoutExtension(regAssembly.Location) + ".tlb");

            RegistrationServices regSrv = new RegistrationServices();
            regSrv.UnregisterAssembly(regAssembly);

            EsriRegasm(false);
            if (File.Exists(tlbPath)) Regasm(false, regAssembly.Location);
        }
Exemplo n.º 34
0
 public virtual int RegisterTypeForComClients(Type type, RegistrationClassContext classContext, RegistrationConnectionType flags)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     if (type as RuntimeType == null)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
     }
     if (!this.TypeRequiresRegistration(type))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_TypeMustBeComCreatable"), "type");
     }
     return(RegistrationServices.RegisterTypeForComClientsExNative(type, classContext, flags));
 }
Exemplo n.º 35
0
 public virtual void RegisterTypeForComClients(Type type, ref Guid g)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     if (type as RuntimeType == null)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
     }
     if (!this.TypeRequiresRegistration(type))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_TypeMustBeComCreatable"), "type");
     }
     RegistrationServices.RegisterTypeForComClientsNative(type, ref g);
 }
Exemplo n.º 36
0
        public override void Install(IDictionary stateSaver)
        {
            //This effectively does what gacutil does.
            //TODO: Make Path a Parameter for InstallUtil

            /*
             * To pass parameters using InstallUtil, the following is an example of passing the ServiceName:
             * InstallUtil /ServiceName="My Custom Service Name" MyCustomService.exe
             * To access this in the ProjectInstaller / ServiceInstaller, you can simply use the following code:
             * Context.Parameters["ServiceName"]
             *
             */

            new System.EnterpriseServices.Internal.Publish().GacInstall("EvilWMIProvider.dll");

            base.Install(stateSaver);
            System.Runtime.InteropServices.RegistrationServices RS = new System.Runtime.InteropServices.RegistrationServices();
        }
Exemplo n.º 37
0
 public override void Install(IDictionary stateSaver)
 {
     new System.EnterpriseServices.Internal.Publish().GacInstall("EvilWMIProvider.dll");
     base.Install(stateSaver);
     System.Runtime.InteropServices.RegistrationServices RS = new System.Runtime.InteropServices.RegistrationServices();
 }
Exemplo n.º 38
0
 public virtual bool TypeRequiresRegistration(Type type)
 {
     return(RegistrationServices.TypeRequiresRegistrationHelper(type));
 }
Exemplo n.º 39
0
 public virtual void UnregisterTypeForComClients(int cookie)
 {
     RegistrationServices.CoRevokeClassObject(cookie);
 }