public override void Uninstall(IDictionary savedState) { try { InstallUtils.InstallModeEnum installMode = (InstallUtils.InstallModeEnum)savedState["InstallMode"]; string pathToAddinFile = (string)savedState["PathToAddinFile"]; InstallUtils.UninstallRegistryFree(savedState, pathToAddinFile); } catch { } base.Uninstall(savedState); }
public override void Install(IDictionary stateSaver) { try { base.Install(stateSaver); InstallUtils.InstallModeEnum installMode = InstallUtils.InstallModeEnum.kRegistryFree; Assembly Asm = Assembly.GetExecutingAssembly(); FileInfo asmFile = new FileInfo(Asm.Location); stateSaver.Add("InstallMode", (int)installMode); stateSaver.Add("PathToAddinFile", InstallUtils.InstallRegistryFree( stateSaver, Asm, InstallUtils.RegFreeModeEnum.kVersionIndep, string.Empty)); // Example for version dependent //stateSaver.Add("PathToAddinFile", // InstallUtils.InstallRegistryFree( // stateSaver, // Asm, // InstallUtils.RegFreeModeEnum.kVersionDep, // "Inventor 2012")); } catch (InstallException ex) { throw new InstallException(ex.Message); } catch { throw new InstallException("Error installing addin!"); } }
public override void Uninstall(IDictionary savedState) { try { InstallUtils.InstallModeEnum installMode = (InstallUtils.InstallModeEnum)savedState["InstallMode"]; string pathToAddinFile; switch (installMode) { case InstallUtils.InstallModeEnum.kRegistryFree: pathToAddinFile = (string)savedState["PathToAddinFile"]; InstallUtils.UninstallRegistryFree(savedState, pathToAddinFile); break; case InstallUtils.InstallModeEnum.kRegistry: InstallUtils.UninstallRegistry(savedState, GetType().Assembly); break; case InstallUtils.InstallModeEnum.kBoth: InstallUtils.UninstallRegistry(savedState, GetType().Assembly); pathToAddinFile = (string)savedState["PathToAddinFile"]; InstallUtils.UninstallRegistryFree(savedState, pathToAddinFile); break; default: break; } } catch { } base.Uninstall(savedState); }
public override void Install(IDictionary stateSaver) { try { base.Install(stateSaver); InstallUtils.InstallModeEnum installMode = InstallUtils.InstallModeEnum.kRegistryFree; Assembly Asm = Assembly.GetExecutingAssembly(); FileInfo asmFile = new FileInfo(Asm.Location); stateSaver.Add("InstallMode", (int)installMode); switch (installMode) { case InstallUtils.InstallModeEnum.kRegistryFree: stateSaver.Add("PathToAddinFile", InstallUtils.InstallRegistryFree( stateSaver, Asm, InstallUtils.RegFreeModeEnum.kVersionIndep, string.Empty)); // Example for version dependent //stateSaver.Add("PathToAddinFile", // InstallUtils.InstallRegistryFree( // stateSaver, // Asm, // InstallUtils.RegFreeMode.kVersionDep, // "Inventor 2012")); break; case InstallUtils.InstallModeEnum.kRegistry: InstallUtils.InstallRegistry(stateSaver, GetType().Assembly); break; case InstallUtils.InstallModeEnum.kBoth: InstallUtils.InstallRegistry(stateSaver, GetType().Assembly); //Only value that works for kBoth install mode is kUserOverride stateSaver.Add("PathToAddinFile", InstallUtils.InstallRegistryFree( stateSaver, Asm, InstallUtils.RegFreeModeEnum.kUserOverride, "Inventor 2012")); break; default: break; } } catch (InstallException ex) { throw new InstallException(ex.Message); } catch { throw new InstallException("Error installing addin!"); } }