public static void UnregisterSelf() { RegistrationServices aRS = new RegistrationServices(); Assembly thisAssembly = Assembly.GetExecutingAssembly(); if (thisAssembly != null) aRS.UnregisterAssembly(thisAssembly); }
/// <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"); } }
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); } } }
public override void Uninstall(IDictionary savedState) { base.Uninstall(savedState); Assembly asm = Assembly.GetExecutingAssembly(); RegistrationServices reg = new RegistrationServices(); reg.UnregisterAssembly(asm); }
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���܂���"); } }
/// <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"); } }
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); }
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ツールバーの登録解除に失敗しました"); } }
public static void UnregisterServer( Assembly assemblyToRegister ) { if ( ComUnregister != null ) { RegistrationServices reg = new RegistrationServices(); reg.UnregisterAssembly( assemblyToRegister ); ComUnregister(); } }
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"); } }
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..."); }
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); } }
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); } }
/// <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); }
public override void Uninstall(IDictionary savedState) { try { base.Uninstall (savedState); RegistrationServices theRS = new RegistrationServices(); if (theRS.UnregisterAssembly(base.GetType().Assembly) == false) { throw new InstallException("Failed to unregister for COM"); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString(), "Error During Uninstallation"); } }
public override void Uninstall(IDictionary savedState) { try { base.Uninstall(savedState); RegistrationServices regsrv = new RegistrationServices(); if (!regsrv.UnregisterAssembly(base.GetType().Assembly)) { throw (new InstallException("Failed To Unregister for COM")); } } catch (InstallException ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "Error during unistallation"); } }
private void Regasm(bool register) { string file = base.Context.Parameters["Assembly"]; if (string.IsNullOrEmpty(file)) throw new InstallException("Assembly not defined"); if (!File.Exists(file)) return; RegistrationServices regsrv = new RegistrationServices(); Assembly assembly = Assembly.LoadFrom(file); if (register) { regsrv.RegisterAssembly(assembly, AssemblyRegistrationFlags.SetCodeBase); } else { try { regsrv.UnregisterAssembly(assembly); } catch { //Exceptions are ignored: even if the unregistering failes //it should notprevent the user from uninstalling } } }
public override void Uninstall(IDictionary savedState) { base.Uninstall(savedState); bool is64 = false; IsWow64Process(Process.GetCurrentProcess().Handle, out is64); if(is64) { RegAsm64("/u"); } else { RegistrationServices regsrv = new RegistrationServices(); regsrv.UnregisterAssembly(GetType().Assembly); } base.Uninstall(savedState); }
public static void Uninstall() { Assembly objAssembly = Assembly.GetExecutingAssembly(); RegistrationServices objRegServices = new RegistrationServices(); try { objRegServices.UnregisterAssembly(objAssembly); RegistryKey objRK = Registry.LocalMachine.OpenSubKey(PATH_APPROVED, true); objRK.DeleteValue(BuildHandler.CLSID); objRK.Close(); Registry.ClassesRoot.DeleteSubKey(PATH_RBUILD); }//try catch (Exception Ex) { Console.WriteLine(Ex.Message); }//catch }
/// <summary> /// Custom Install Action that removes the COM Interop component registrations. /// Note that this will in turn trigger any methods with the [ComUnregisterFunction()] attribute /// such as those in Driver.cs that remove the ASCOM registration. /// </summary> /// <param name="savedState">Not used.<see cref="Installer"/></param> public override void Uninstall(System.Collections.IDictionary savedState) { Trace.WriteLine("Uninstall custom action - unregistering from COM Interop"); try { base.Uninstall(savedState); RegistrationServices regsrv = new RegistrationServices(); if (!regsrv.UnregisterAssembly(this.GetType().Assembly)) { Trace.WriteLine("COM Interop deregistration failed"); throw new InstallException("Failed To Unregister from COM Interop"); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } finally { Trace.WriteLine("Completed uninstall custom action"); } }
public static void Main(string[] args) { var asm = Assembly.GetExecutingAssembly(); var registrar = new RegistrationServices(); char ch; if (args.Any(a => a == "--register")) ch = 'Y'; else if (args.Any(a => a == "--unregister")) ch = 'U'; else { Console.WriteLine("Would you like to register the \"LLLPG\" custom tool in Visual Studio? "); Console.Write("Y=Register, U=Unregister: "); ch = char.ToUpper(Console.ReadKey().KeyChar); Console.WriteLine(); } if (ch == 'Y' || ch == 'R') { // Who the hell knows whether this will work on other people's machines //string mypath = @"""" + Assembly.GetExecutingAssembly().Location + @""""; //Console.WriteLine("Trying to invoke regasm.exe to register this file."); //if (!TryStart(@"regasm.exe", mypath)) // if (!TryStart(@"C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm.exe", mypath)) // if (!TryStart(@"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe", mypath)) { // Console.WriteLine(); // Console.WriteLine("That didn't work, but you can still find and invoke it manually."); // Console.WriteLine("Just pass this module as an argument to regasm.exe."); // } // Found a better way! bool ok = registrar.RegisterAssembly(asm, AssemblyRegistrationFlags.SetCodeBase); Console.WriteLine(ok ? "Registered OK" : "Fail (No eligible types?!)"); } else if (ch == 'U') { bool ok = registrar.UnregisterAssembly(asm); Console.WriteLine(ok ? "Unregistered OK" : "Fail (No eligible types?!)"); } else Console.WriteLine("Exit."); }
/////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// public void RegisterSystemWebAssembly(int doReg, out IntPtr exception) { exception = IntPtr.Zero; try { Assembly webAssembly = Assembly.GetExecutingAssembly(); RegistrationServices rs = new RegistrationServices(); if (doReg != 0) { if (!rs.RegisterAssembly(webAssembly, AssemblyRegistrationFlags.None)) exception = Marshal.StringToBSTR((new Exception(SR.GetString(SR.Unable_To_Register_Assembly, webAssembly.FullName))).ToString()); } else { if (!rs.UnregisterAssembly(webAssembly)) exception = Marshal.StringToBSTR((new Exception(SR.GetString(SR.Unable_To_UnRegister_Assembly, webAssembly.FullName))).ToString()); } } catch (Exception e) { exception = Marshal.StringToBSTR(e.ToString()); } }
private void DoUnRegister() { try { OverrideHKCR(); var rs = new RegistrationServices(); rs.UnregisterAssembly(Assembly.LoadFrom(Path.Combine(crtDir, @"LEContextMenuHandler.dll"))); OverrideHKCR(true); } catch (Exception e) { MessageBox.Show(e.Message + "\r\n\r\n" + e.StackTrace); } }
private static void Main(string[] args) { string dll = "", name = ""; bool remove = false, quiet = false; try { if (args.Length < 3) { Console.WriteLine("Usage: register.exe filename.dll COMname GUID [remove]"); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); return; } dll = args[0];//bin/XnaPlus.Effect.dll name = args[1];//XnaFX string guid = args[2];//{F3829EFE-0362-4FE4-928A-7784A6334E76} if (File.Exists(dll) == false) { Console.WriteLine("File: " + dll + " Does not exist"); MessageBox.Show("File: " + dll + " Does not exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); return; } if (args.Length > 3 && args[3].Contains("remove")) remove = true; if (args.Length > 3 && args[3].Contains("quiet")) quiet = true; string[] reg = new string[] { @"SOFTWARE\Microsoft\VCSExpress\10.0\Generators\", @"SOFTWARE\Microsoft\VBExpress\10.0\Generators\", @"SOFTWARE\Microsoft\VisualStudio\10.0\Generators\", //x64 @"SOFTWARE\Wow6432Node\Microsoft\VCSExpress\10.0\Generators\", @"SOFTWARE\Wow6432Node\Microsoft\VBExpress\10.0\Generators\", @"SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Generators\", }; try { foreach (string rootkey in reg) { RegistryKey key = Registry.LocalMachine.OpenSubKey(rootkey); if (key == null) continue; string[] names = key.GetSubKeyNames(); foreach (string keyname in names) { RegistryKey sub = key.OpenSubKey(keyname, true); string[] subs = sub.GetSubKeyNames(); foreach (string subkeyname in subs) { if (subkeyname == name) { sub.DeleteSubKey(name); } } if (!remove) { RegistryKey namedKey = sub.CreateSubKey(name); namedKey.SetValue("CLSID", guid, RegistryValueKind.String); namedKey.SetValue("GeneratesDesignTimeSource", (int)1, RegistryValueKind.DWord); namedKey.Close(); } sub.Close(); } } } catch (Exception e) { string error = "An error occured while writing registry data" + Environment.NewLine + "(This application may require administrator privaleges to run properly)" + Environment.NewLine + Environment.NewLine + e.ToString(); MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Console.WriteLine(error); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); return; } //I have no idea why this is occasionally needed...? System.AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); Assembly asm = Assembly.LoadFrom(Path.GetFullPath(dll)); bool complete; RegistrationServices register = new RegistrationServices(); if (remove) complete = register.UnregisterAssembly(asm); else complete = register.RegisterAssembly(asm, AssemblyRegistrationFlags.SetCodeBase); if (complete) Console.WriteLine("Operation complete"); else { if (remove) Console.WriteLine("Operation failed (Type may already be removed)"); else Console.WriteLine("Operation failed"); } if (!quiet) { Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } } catch (Exception ex) { if (!quiet) System.Windows.Forms.MessageBox.Show( string.Format(@"Failed to {0} assembly {1} If the .dll is already registered, it may need to be manually removed from the GAC. To do this, in Explorer, navigate to %windir%\assembly Find the assembly in the list, and manually remove it by right clicking and selecting 'Uninstall' Exception: {2}", remove ? "unregister" : "register", dll, ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Console.WriteLine(@"{2}: Failed to {0} assembly {1}", remove ? "unregister" : "register", dll, typeof(Program).Assembly.ManifestModule.Name); Console.Error.WriteLine(@"Failed to {0} assembly {1}", remove ? "unregister" : "register", dll); } }
private static void UnRegasm() { var t = Type.GetType(classid); if (t == null) throw new Exception("cannot get type for " + classid); var regSvcs = new RegistrationServices(); regSvcs.UnregisterAssembly(t.Assembly); WriteLine("{0} unregistered from COM", classid); }
public static void Unregister() { try { RegistrationServices svc = new RegistrationServices(); svc.UnregisterAssembly(typeof(Program).Assembly); } catch (Exception e) { throw new ApplicationException(e.Message, e); } }
/// <summary> /// When overridden in a derived class, removes an installation. /// </summary> /// <param name="savedState">An <see cref="T:System.Collections.IDictionary"/> that contains the state of the computer after the installation was complete.</param> public override void Uninstall(IDictionary savedState) { try { RegistrationServices regServices = new RegistrationServices(); regServices.UnregisterAssembly(GetType().Assembly); } catch { } finally { base.Uninstall(savedState); } }
public override void Unregister(RegistrationContext context) { context.Log.WriteLine("Unregistering debug engine...."); context.RemoveKey(EngineRegKey); var clsidAttributes = context.ComponentType.GetCustomAttributes(typeof(ClsidAttribute), false).Cast<ClsidAttribute>(); foreach (var clsidAttribute in clsidAttributes) { var fileName = new FileInfo(clsidAttribute.CodeBase); var asm = Assembly.LoadFrom(fileName.FullName); var regAsm = new RegistrationServices(); if (!regAsm.UnregisterAssembly(asm)) { context.Log.WriteLine("Failed to unregister assembly " + clsidAttribute.CodeBase); throw new Exception("Failed to unregister: " + clsidAttribute.CodeBase); } File.Delete(fileName.FullName); context.RemoveKey(String.Format("CLSID\\{0}", clsidAttribute.Clsid)); } }
public override void Uninstall(System.Collections.IDictionary savedState) { base.Uninstall(savedState); RegistrationServices regSrv = new RegistrationServices(); regSrv.UnregisterAssembly(base.GetType().Assembly); }
/// <summary> /// Unregisters the CLSID for the FileSyncHandler. Callable from installers. /// </summary> /// <param name="savedState">An IDictionary that contains the state of the computer after the installation was complete.</param> /// <exception cref="System.Configuration.Install.InstallException">Thrown when the assembly can't be unregistered.</exception> public override void Uninstall(IDictionary savedState) { System.Diagnostics.Trace.WriteLine("Starting Uninstall"); base.Uninstall (savedState); RegistrationServices regsrv = new RegistrationServices(); if (!regsrv.UnregisterAssembly(this.GetType().Assembly)) { throw new InstallException("Failed To Unregister for COM"); } System.Diagnostics.Trace.WriteLine("Unnstall succeeded"); }