internal RegistrationThreadWrapper(RegistrationHelper helper, RegistrationConfig regConfig) { DBG.Info(DBG.Registration, "STA Thread! jumping onto MTA for registration"); _regConfig = regConfig; _helper = helper; _exception = null; }
static void Main(string[] args) { // Register a private assembly. RegistrationHelper rh = new RegistrationHelper(); try { string comPlusAppName = "NewComPlusApp"; string typeLibName = "FooServicedComp.tlb"; rh.InstallAssembly("FooServicedComp.dll", ref comPlusAppName, ref typeLibName, InstallationFlagsFindOrCreateTargetApplication); } catch(RegistrationException rhex) { Console.WriteLine(rhex.Message); } }
// Install an assembly given configuration information. public void InstallAssemblyFromConfig (ref RegistrationConfig regConfig, Object sync) { RegistrationHelper helper; bool complete = false; try { helper = new RegistrationHelper(); helper.InstallAssemblyFromConfig(ref regConfig); ContextUtil.SetComplete(); complete = true; } finally { if (!complete) { ContextUtil.SetAbort(); } } }
/// <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); string appID = string.Empty; string typeLib = string.Empty; // Get the location of the current assembly string assemblyLocation = GetType().Assembly.Location; // Install the application try { RegistrationHelper regHelper = new RegistrationHelper(); regHelper.InstallAssembly(assemblyLocation, ref appID, ref typeLib, InstallationFlags.FindOrCreateTargetApplication); // Save the state - you will need this for the uninstall stateSaver.Add("AppID", appID); stateSaver.Add("Assembly", assemblyLocation); } catch (Exception ex) { throw new InstallException("Error during registration of " + GetType().Assembly.FullName, ex); } }
/// <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 { // Get the state created when the app was installed string appID = (string)savedState["AppID"]; string assembly = (string)savedState["Assembly"]; // Uninstall the application RegistrationHelper regHelper = new RegistrationHelper(); regHelper.UninstallAssembly(assembly, appID); } catch (Exception) { } finally { base.Uninstall(savedState); } }
internal RegistrationThreadWrapper(RegistrationHelper helper, RegistrationConfig regConfig) { this._regConfig = regConfig; this._helper = helper; this._exception = null; }
// Install an assembly given configuration information. public void InstallAssemblyFromConfig (ref RegistrationConfig regConfig, Object sync) { RegistrationHelper helper; bool complete = false; try { helper = new RegistrationHelper(); helper.InstallAssemblyFromConfig(ref regConfig); ContextUtil.SetComplete(); complete = true; } finally { if(!complete) { ContextUtil.SetAbort(); } } }
/// <summary> /// /// </summary> /// <param name="assemblyFile"></param> public void UnregisterServicedComponents(FileInfo assemblyFile) { RegistrationConfig config = new RegistrationConfig(); config.Application = applicationName; config.AssemblyFile = assemblyFile.FullName; config.InstallationFlags = InstallationFlags.ReportWarningsToConsole | InstallationFlags.FindOrCreateTargetApplication | InstallationFlags.ReconfigureExistingApplication; RegistrationHelper regHelper = new RegistrationHelper(); regHelper.UninstallAssemblyFromConfig(ref config); }