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 }
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 Install(System.Collections.IDictionary stateSaver) { base.Install(stateSaver); RegistrationServices regSrv = new RegistrationServices(); regSrv.RegisterAssembly(base.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase); }
/// <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); }
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); }
/// <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 Register() { try { RegistrationServices svc = new RegistrationServices(); svc.RegisterAssembly(typeof (Program).Assembly, AssemblyRegistrationFlags.SetCodeBase); } catch (Exception e) { throw new ApplicationException(e.Message, e); } }
public static void RegisterServer( Assembly assemblyToRegister ) { if ( ComRegister != null ) { RegistrationServices reg = new RegistrationServices(); reg.RegisterAssembly( assemblyToRegister, AssemblyRegistrationFlags.SetCodeBase ); ComRegister(); } }
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); }
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"); } }
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ツールバーの登録に失敗しました"); } }
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"); } }
/// <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); }
/// <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"); }
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); } }
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"); } }
/// <summary> /// Registers the CLSID for the FileSyncHandler so that it can be invoked as /// a COM object from SyncMgr. Callable from installers. /// </summary> /// <param name="stateSaver">An IDictionary used to save information needed to perform a commit, rollback, or uninstall operation.</param> /// <exception cref="System.Configuration.Install.InstallException">Thrown when the assembly can't be registered.</exception> public override void Install(IDictionary stateSaver) { System.Diagnostics.Trace.WriteLine("Starting Install"); base.Install (stateSaver); RegistrationServices regsrv = new RegistrationServices(); if (!regsrv.RegisterAssembly(this.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase)) { System.Diagnostics.Trace.WriteLine("Install failed"); throw new InstallException("Failed To Register for COM"); } System.Diagnostics.Trace.WriteLine("Install succeeded"); }
public void Register() { Assembly[] assemblies = m_regData.GetAssemblies(); RegistrationServices regServ = new RegistrationServices(); foreach (Assembly assembly in assemblies) { Write( "Registering .NET/COM Components: "+assembly.Location+"..." ); bool success = regServ.RegisterAssembly(assembly, System.Runtime.InteropServices.AssemblyRegistrationFlags.SetCodeBase); if (success) WriteLine( "Done." ); else ReportError( "Failed to register .NET/COM assembly "+assembly.Location ); } }
private bool RegisterAsDotNetComObject(string filePath) { try { Assembly assembly = Assembly.LoadFrom(filePath); var regSvc = new RegistrationServices(); return regSvc.RegisterAssembly(assembly, AssemblyRegistrationFlags.SetCodeBase); } catch (Exception) { return false; } }
public override void Install(IDictionary stateSaver) { try { base.Install (stateSaver); RegistrationServices theRS = new RegistrationServices(); if (theRS.RegisterAssembly(base.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase) == false) { throw new InstallException("Failed to register for COM"); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString(), "Error During Installation"); } }
/// <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(); } }
public override void Install(IDictionary stateSaver) { try { base.Install(stateSaver); RegistrationServices regsrv = new RegistrationServices(); if (!regsrv.RegisterAssembly(base.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase)) { throw (new InstallException("Failed To Register for COM")); } } catch (InstallException ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "Error during installation"); } }
public override void Install(IDictionary stateSaver) { base.Install(stateSaver); bool is64 = false; IsWow64Process(Process.GetCurrentProcess().Handle, out is64); if(is64) { RegAsm64("/codebase"); } else { RegistrationServices regsrv = new RegistrationServices(); regsrv.RegisterAssembly(GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase); } }
private static void CheckJanusProtocolInstallation() { try { JanusProtocol.SetDataSource(new JanusInternalResourceProvider()); var rs = new RegistrationServices(); rs.RegisterAssembly(typeof(JanusProtocol).Assembly, AssemblyRegistrationFlags.SetCodeBase); } catch (Exception ex) { MessageBox.Show( string.Format(SR.Application.ProtocolInstallationError, ex.Message), ApplicationInfo.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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 } } }
/// <summary> /// Custom Install Action that regsiters the driver with COM Interop. /// Note that this will in turn trigger an methods with the [ComRegisterFunction()] attribute /// such as those in Driver.cs that perform ASCOM registration. /// </summary> /// <param name="stateSaver">Not used.<see cref="Installer"/></param> public override void Install(System.Collections.IDictionary stateSaver) { string msg = "Install custom action - Starting registration for COM Interop"; Trace.WriteLine(msg); #if DEBUG MessageBox.Show("Attach debugger to this process now, if required", "Custom Action Debug", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); #endif 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 driver for COM Interop"); } Trace.WriteLine("Completed registration for COM Interop"); }
public override void Install(IDictionary stateSaver) { base.Install(stateSaver); Assembly regAssembly = base.GetType().Assembly; string tlbPath = Path.Combine(Path.GetDirectoryName(regAssembly.Location), Path.GetFileNameWithoutExtension(regAssembly.Location) + ".tlb"); if (File.Exists(tlbPath)) { RegistrationServices regSrv = new RegistrationServices(); regSrv.RegisterAssembly(regAssembly, AssemblyRegistrationFlags.SetCodeBase); } else { Regasm(true, regAssembly.Location); } EsriRegasm(true); }
public override void Commit(System.Collections.IDictionary savedState) { base.Commit(savedState); /* // Get the location of regasm string regasmPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + @"regasm.exe"; if (!File.Exists(regasmPath)) { regasmPath = @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe"; } // Get the location of our DLL string componentPath = typeof(ShellExtensionSetup).Assembly.Location; // Execute regasm System.Diagnostics.Process.Start(regasmPath, "/codebase \"" + componentPath + "\"");*/ Assembly asm = Assembly.GetExecutingAssembly(); RegistrationServices reg = new RegistrationServices(); reg.RegisterAssembly(asm, 0); }
public override void Install(IDictionary stateSaver) { try { base.Install (stateSaver); //System.Diagnostics.Debugger.Break(); // Update the ISDUT_Defaults.txt file this.AlterDefaultsFile(); // COM Registration RegistrationServices theRS = new RegistrationServices(); if (theRS.RegisterAssembly(base.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase) == false) { throw new InstallException("Failed to register for COM"); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString(), "Error During Installation"); } }
public override void Install(System.Collections.IDictionary stateSaver) { base.Install(stateSaver); RegistrationServices regSrv = new RegistrationServices(); regSrv.RegisterAssembly(base.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase); //Add a new context menu item. RegistryKey regmenu = null; RegistryKey regcmd = null; try { regmenu = Registry.ClassesRoot.CreateSubKey(MenuName); if(regmenu != null) regmenu.SetValue("", "Sync with OneSync 4"); regcmd = Registry.ClassesRoot.CreateSubKey(Command); if(regcmd != null) regcmd.SetValue("", "\"" + Assembly.GetExecutingAssembly().Location + "\" \"%1\""); regmenu = Registry.ClassesRoot.CreateSubKey(AppMenuName); if (regmenu != null) regmenu.SetValue("", "Open OneSync 4"); regcmd = Registry.ClassesRoot.CreateSubKey(AppCommand); if (regcmd != null) regcmd.SetValue("", "\"" + Assembly.GetExecutingAssembly().Location + "\""); } catch(Exception) { //Do nothing?! } finally { if(regmenu != null) regmenu.Close(); if(regcmd != null) regcmd.Close(); } }
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."); }