internal ApplicationSpec(System.Reflection.Assembly asm, RegistrationConfig regConfig) { this._asm = asm; this._regConfig = regConfig; this.GenerateNames(); this.ReadTypes(); }
// Uninstall an assembly. public void UninstallAssembly (String assembly, String application, String partition) { RegistrationConfig config = new RegistrationConfig(); config.AssemblyFile = assembly; config.Application = application; UninstallAssemblyFromConfig(ref config); }
public void UninstallAssembly (String assembly, String application, String partition, Object sync) { RegistrationConfig config = new RegistrationConfig(); config.AssemblyFile = assembly; config.Application = application; UninstallAssemblyFromConfig(ref config, sync); }
public void InstallAssembly (String assembly, ref String application, String partition, ref String tlb, InstallationFlags installFlags, Object sync) { RegistrationConfig config = new RegistrationConfig(); config.AssemblyFile = assembly; config.Application = application; config.Partition = partition; config.TypeLibrary = tlb; config.InstallationFlags = installFlags; InstallAssemblyFromConfig(ref config, sync); application = config.Application; tlb = config.TypeLibrary; }
public void InstallAssembly(string assembly, ref string application, string partition, ref string tlb, InstallationFlags installFlags, object sync) { RegistrationConfig regConfig = new RegistrationConfig { AssemblyFile = assembly, Application = application, Partition = partition, TypeLibrary = tlb, InstallationFlags = installFlags }; this.InstallAssemblyFromConfig(ref regConfig, sync); application = regConfig.AssemblyFile; tlb = regConfig.TypeLibrary; }
// Implementation: /// <include file='doc\RegistrationWrappers.uex' path='docs/doc[@for="RegistrationHelperTx.InstallAssembly1"]/*' /> public void InstallAssembly(String assembly, ref String application, String partition, ref String tlb, InstallationFlags installFlags, Object sync) { RegistrationConfig regConfig = new RegistrationConfig(); regConfig.AssemblyFile = assembly; regConfig.Application = application; regConfig.Partition = partition; regConfig.TypeLibrary = tlb; regConfig.InstallationFlags = installFlags; InstallAssemblyFromConfig(ref regConfig, sync); application = regConfig.AssemblyFile; tlb = regConfig.TypeLibrary; }
// Install an assembly. public void InstallAssembly (String assembly, ref String application, String partition, ref String tlb, InstallationFlags installFlags) { RegistrationConfig config = new RegistrationConfig(); config.AssemblyFile = assembly; config.Application = application; config.Partition = partition; config.TypeLibrary = tlb; config.InstallationFlags = installFlags; InstallAssemblyFromConfig(ref config); application = config.Application; tlb = config.TypeLibrary; }
private bool TryTransactedUninstall(RegistrationConfig regConfig) { Perf.Tick("RegistrationHelper - Object creation (uninstall)"); RegistrationHelperTx reg = null; try { reg = new RegistrationHelperTx(); if (!reg.IsInTransaction()) { reg = null; } // reg is now bound into a transactional context? do transactional work: } catch (Exception e) { DBG.Info(DBG.Registration, "Transacted uninstall failed w/ " + e); try { EventLog appLog = new EventLog(); appLog.Source = "System.EnterpriseServices"; String errMsg = String.Format(Resource.FormatString("Reg_ErrTxUninst"), e); appLog.WriteEntry(errMsg, EventLogEntryType.Error); } catch {} // We don't want to fail... fall back as we were before. } // Couldn't set up to do a transactional install if (reg == null) { return(false); } // HACK: We have to pass in this CatalogSync object, which we use // so that we can watch until the CLB is updated on disc, because // there is a CRM bug in Win2K which keeps us from CatalogSync sync = new CatalogSync(); reg.UninstallAssemblyFromConfig(ref regConfig, sync); sync.Wait(); Perf.Tick("RegistrationHelper - Done"); return(true); }
public void UninstallAssemblyFromConfig([MarshalAs(UnmanagedType.IUnknown)] ref RegistrationConfig regConfig, object sync) { bool flag = false; try { new RegistrationDriver().UninstallAssembly(regConfig, sync); ContextUtil.SetComplete(); flag = true; } finally { if (!flag) { ContextUtil.SetAbort(); } } }
// 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(); } } }
// 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(); } } }
/// <include file='doc\RegistrationWrappers.uex' path='docs/doc[@for="RegistrationHelper.InstallAssemblyFromConfig"]/*' /> public void InstallAssemblyFromConfig([MarshalAs(UnmanagedType.IUnknown)] ref RegistrationConfig regConfig) { // Create a permission object for unmanaged code SecurityPermission sp = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode); // demand that the caller have this permission sp.Demand(); // now that the caller is clean, assert it from now on. sp.Assert(); Platform.Assert(Platform.W2K, "RegistrationHelper.InstallAssemblyFromConfig"); if (Thread.CurrentThread.ApartmentState == ApartmentState.STA) { // HACK: In order to reduce deadlock likelihood, we need to get off // the current STA (into an MTA) in order to do this work. // Whip off a new thread... RegistrationThreadWrapper wrap = new RegistrationThreadWrapper(this, regConfig); Thread t = new Thread(new ThreadStart(wrap.InstallThread)); t.Start(); t.Join(); wrap.PropInstallResult(); } else { // First, try to do this in a "transacted" manner. This will // return false if we couldn't start up the transaction, // true if it succeeded. // We only do the transacted install if we're on win2k or higher, // cause MTS is all in the registry. if (Platform.IsLessThan(Platform.W2K) || !TryTransactedInstall(regConfig)) { // We need to try a non-transacted install: DBG.Info(DBG.Registration, "Failed to do a transacted install. Using non-tx install."); RegistrationDriver helper = new RegistrationDriver(); helper.InstallAssembly(regConfig, null); } } }
/// <include file='doc\RegistrationWrappers.uex' path='docs/doc[@for="RegistrationHelperTx.UninstallAssemblyFromConfig"]/*' /> public void UninstallAssemblyFromConfig([MarshalAs(UnmanagedType.IUnknown)] ref RegistrationConfig regConfig, Object sync) { bool succeed = false; try { DBG.Assert(ContextUtil.IsInTransaction, "Running in transactional helper w/o transaction will deadlock!"); RegistrationDriver helper = new RegistrationDriver(); helper.UninstallAssembly(regConfig, sync); ContextUtil.SetComplete(); succeed = true; } finally { if (!succeed) { DBG.Info(DBG.Registration, "Uninstall failed."); ContextUtil.SetAbort(); } } }
public void UninstallAssembly(RegistrationConfig regConfig, object obSync) { CatalogSync sync = null; SecurityPermission permission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode); permission.Demand(); permission.Assert(); if (obSync != null) { if (!(obSync is CatalogSync)) { throw new ArgumentException(Resource.FormatString("Err_obSync")); } sync = (CatalogSync)obSync; } Assembly asm = this.NewLoadAssembly(regConfig.AssemblyFile); ApplicationSpec spec = new ApplicationSpec(asm, regConfig); if (spec.ConfigurableTypes != null) { this.PrepDriver(ref spec); if (spec.ConfigurableTypes != null) { ICatalogObject obj2 = this.FindApplication(this._appColl, spec); if (obj2 == null) { throw new RegistrationException(Resource.FormatString("Reg_AppNotFoundErr", spec)); } ICatalogCollection collection = (ICatalogCollection)this._appColl.GetCollection(CollectionName.Components, obj2.Key()); string[] arr = new string[spec.ConfigurableTypes.Length]; int index = 0; foreach (Type type in spec.ConfigurableTypes) { arr[index] = Marshal.GenerateGuidForType(type).ToString(); index++; } Populate(collection); bool flag = true; int lIndex = 0; while (lIndex < collection.Count()) { ICatalogObject obj3 = (ICatalogObject)collection.Item(lIndex); string g = (string)obj3.Key(); g = new Guid(g).ToString(); if (this.FindIndexOf(arr, g) != -1) { collection.Remove(lIndex); if (sync != null) { sync.Set(); } } else { lIndex++; flag = false; } } SaveChanges(collection); if (flag) { for (int i = 0; i < this._appColl.Count(); i++) { ICatalogObject obj4 = (ICatalogObject)this._appColl.Item(i); if (obj4.Key().Equals(obj2.Key())) { this._appColl.Remove(i); if (sync != null) { sync.Set(); } break; } } SaveChanges(this._appColl); } } this.UnregisterAssembly(asm, spec); this.CleanupDriver(); } }
public void InstallAssembly(RegistrationConfig regConfig, object obSync) { Assembly asm = null; ApplicationSpec spec = null; CatalogSync sync = null; bool flag = false; bool flag2 = false; SecurityPermission permission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode); try { permission.Demand(); permission.Assert(); ICatalogObject app = null; this.PrepArguments(regConfig); asm = this.NewLoadAssembly(regConfig.AssemblyFile); spec = new ApplicationSpec(asm, regConfig); if (spec.ConfigurableTypes == null) { regConfig.Application = null; regConfig.TypeLibrary = null; } else { if (obSync != null) { if (!(obSync is CatalogSync)) { throw new ArgumentException(Resource.FormatString("Err_obSync")); } sync = (CatalogSync)obSync; } this.PrepDriver(ref spec); string message = string.Empty; if (!this.ValidateBitness(spec, out message)) { throw new RegistrationException(message); } if ((regConfig.InstallationFlags & InstallationFlags.Register) != InstallationFlags.Default) { flag = !this.IsAssemblyRegistered(spec); this.ClassicRegistration(spec.Assembly); if ((regConfig.InstallationFlags & InstallationFlags.ExpectExistingTypeLib) != InstallationFlags.Default) { RegisterTypeLibrary(spec.TypeLib); } else { flag2 = true; GenerateTypeLibrary(spec.Assembly, spec.TypeLib, new Report(this.ReportWarning)); } } if (((regConfig.InstallationFlags & InstallationFlags.Install) != InstallationFlags.Default) && (spec.ConfigurableTypes != null)) { if ((regConfig.InstallationFlags & InstallationFlags.CreateTargetApplication) != InstallationFlags.Default) { app = this.CreateApplication(spec, true); } else if ((regConfig.InstallationFlags & InstallationFlags.FindOrCreateTargetApplication) != InstallationFlags.Default) { app = this.FindOrCreateApplication(spec, (regConfig.InstallationFlags & InstallationFlags.ReconfigureExistingApplication) != InstallationFlags.Default); } this.InstallTypeLibrary(spec); if (sync != null) { sync.Set(); } } if (((regConfig.InstallationFlags & InstallationFlags.Configure) != InstallationFlags.Default) && (spec.ConfigurableTypes != null)) { this.ConfigureComponents(spec); if (sync != null) { sync.Set(); } } if (app != null) { this.PostProcessApplication(app, spec); } this.CleanupDriver(); } } catch (Exception exception) { if ((exception is NullReferenceException) || (exception is SEHException)) { throw; } if (((exception is SecurityException) || (exception is UnauthorizedAccessException)) || ((exception.InnerException != null) && ((exception.InnerException is SecurityException) || (exception.InnerException is UnauthorizedAccessException)))) { exception = new RegistrationException(Resource.FormatString("Reg_Unauthorized"), exception); } if (flag && (null != asm)) { try { this.ClassicUnregistration(asm); } catch (Exception exception2) { if ((exception2 is NullReferenceException) || (exception2 is SEHException)) { throw; } } } if (flag2 && (null != asm)) { try { this.UnregisterTypeLib(asm); } catch (Exception exception3) { if ((exception3 is NullReferenceException) || (exception3 is SEHException)) { throw; } } } throw exception; } }
internal RegistrationThreadWrapper(RegistrationHelper helper, RegistrationConfig regConfig) { this._regConfig = regConfig; this._helper = helper; this._exception = null; }
public void InstallAssembly(RegistrationConfig regConfig, object obSync) { Assembly asm = null; ApplicationSpec spec = null; CatalogSync sync = null; bool flag = false; bool flag2 = false; SecurityPermission permission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode); try { permission.Demand(); permission.Assert(); ICatalogObject app = null; this.PrepArguments(regConfig); asm = this.NewLoadAssembly(regConfig.AssemblyFile); spec = new ApplicationSpec(asm, regConfig); if (spec.ConfigurableTypes == null) { regConfig.Application = null; regConfig.TypeLibrary = null; } else { if (obSync != null) { if (!(obSync is CatalogSync)) { throw new ArgumentException(Resource.FormatString("Err_obSync")); } sync = (CatalogSync) obSync; } this.PrepDriver(ref spec); string message = string.Empty; if (!this.ValidateBitness(spec, out message)) { throw new RegistrationException(message); } if ((regConfig.InstallationFlags & InstallationFlags.Register) != InstallationFlags.Default) { flag = !this.IsAssemblyRegistered(spec); this.ClassicRegistration(spec.Assembly); if ((regConfig.InstallationFlags & InstallationFlags.ExpectExistingTypeLib) != InstallationFlags.Default) { RegisterTypeLibrary(spec.TypeLib); } else { flag2 = true; GenerateTypeLibrary(spec.Assembly, spec.TypeLib, new Report(this.ReportWarning)); } } if (((regConfig.InstallationFlags & InstallationFlags.Install) != InstallationFlags.Default) && (spec.ConfigurableTypes != null)) { if ((regConfig.InstallationFlags & InstallationFlags.CreateTargetApplication) != InstallationFlags.Default) { app = this.CreateApplication(spec, true); } else if ((regConfig.InstallationFlags & InstallationFlags.FindOrCreateTargetApplication) != InstallationFlags.Default) { app = this.FindOrCreateApplication(spec, (regConfig.InstallationFlags & InstallationFlags.ReconfigureExistingApplication) != InstallationFlags.Default); } this.InstallTypeLibrary(spec); if (sync != null) { sync.Set(); } } if (((regConfig.InstallationFlags & InstallationFlags.Configure) != InstallationFlags.Default) && (spec.ConfigurableTypes != null)) { this.ConfigureComponents(spec); if (sync != null) { sync.Set(); } } if (app != null) { this.PostProcessApplication(app, spec); } this.CleanupDriver(); } } catch (Exception exception) { if ((exception is NullReferenceException) || (exception is SEHException)) { throw; } if (((exception is SecurityException) || (exception is UnauthorizedAccessException)) || ((exception.InnerException != null) && ((exception.InnerException is SecurityException) || (exception.InnerException is UnauthorizedAccessException)))) { exception = new RegistrationException(Resource.FormatString("Reg_Unauthorized"), exception); } if (flag && (null != asm)) { try { this.ClassicUnregistration(asm); } catch (Exception exception2) { if ((exception2 is NullReferenceException) || (exception2 is SEHException)) { throw; } } } if (flag2 && (null != asm)) { try { this.UnregisterTypeLib(asm); } catch (Exception exception3) { if ((exception3 is NullReferenceException) || (exception3 is SEHException)) { throw; } } } throw exception; } }
public void UninstallAssembly(string assembly, string application, string partition, object sync) { RegistrationConfig regConfig = new RegistrationConfig { AssemblyFile = assembly, Application = application, Partition = partition }; this.UninstallAssemblyFromConfig(ref regConfig, sync); }
public void InstallAssemblyFromConfig([MarshalAs(UnmanagedType.IUnknown)] ref RegistrationConfig regConfig, object sync) { throw new NotImplementedException(); }
private void PrepArguments(RegistrationConfig regConfig) { if ((regConfig.AssemblyFile == null) || (regConfig.AssemblyFile.Length == 0)) { throw new RegistrationException(Resource.FormatString("Reg_ArgumentAssembly")); } if (((regConfig.InstallationFlags & InstallationFlags.ExpectExistingTypeLib) != InstallationFlags.Default) && ((regConfig.TypeLibrary == null) || (regConfig.TypeLibrary.Length == 0))) { throw new RegistrationException(Resource.FormatString("Reg_ExpectExisting")); } if (((regConfig.InstallationFlags & InstallationFlags.CreateTargetApplication) != InstallationFlags.Default) && ((regConfig.InstallationFlags & InstallationFlags.FindOrCreateTargetApplication) != InstallationFlags.Default)) { throw new RegistrationException(Resource.FormatString("Reg_CreateFlagErr")); } if ((((regConfig.InstallationFlags & InstallationFlags.Register) == InstallationFlags.Default) && ((regConfig.InstallationFlags & InstallationFlags.Install) == InstallationFlags.Default)) && ((regConfig.InstallationFlags & InstallationFlags.Configure) == InstallationFlags.Default)) { regConfig.InstallationFlags |= InstallationFlags.Configure | InstallationFlags.Install | InstallationFlags.Register; } this._installFlags = regConfig.InstallationFlags; if ((regConfig.Partition != null) && (regConfig.Partition.Length != 0)) { string strB = "Base Application Partition"; string str2 = "{41E90F3E-56C1-4633-81C3-6E8BAC8BDD70}"; if ((string.Compare(regConfig.Partition, str2, StringComparison.OrdinalIgnoreCase) == 0) || (string.Compare(regConfig.Partition, strB, StringComparison.OrdinalIgnoreCase) == 0)) { regConfig.Partition = null; } } if ((regConfig.ApplicationRootDirectory != null) && !Directory.Exists(regConfig.ApplicationRootDirectory)) { throw new RegistrationException(Resource.FormatString("Reg_BadAppRootDir")); } }
internal RegistrationThreadWrapper(RegistrationHelper helper, RegistrationConfig regConfig) { this._regConfig = regConfig; this._helper = helper; this._exception = null; }
/// <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); }
public void InstallAssembly(string assembly, ref string application, string partition, ref string tlb, InstallationFlags installFlags, object sync) { RegistrationConfig regConfig = new RegistrationConfig { AssemblyFile = assembly, Application = application, Partition = partition, TypeLibrary = tlb, InstallationFlags = installFlags }; this.InstallAssemblyFromConfig(ref regConfig, sync); application = regConfig.AssemblyFile; tlb = regConfig.TypeLibrary; }
// Uninstall an assembly given configuration information. public void UninstallAssemblyFromConfig(ref RegistrationConfig regConfig) { throw new SecurityException(); }
// Uninstall an assembly given configuration information. public void UninstallAssemblyFromConfig(ref RegistrationConfig regConfig) { throw new SecurityException(); }
public void UninstallAssembly(RegistrationConfig regConfig, object obSync) { CatalogSync sync = null; SecurityPermission permission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode); permission.Demand(); permission.Assert(); if (obSync != null) { if (!(obSync is CatalogSync)) { throw new ArgumentException(Resource.FormatString("Err_obSync")); } sync = (CatalogSync) obSync; } Assembly asm = this.NewLoadAssembly(regConfig.AssemblyFile); ApplicationSpec spec = new ApplicationSpec(asm, regConfig); if (spec.ConfigurableTypes != null) { this.PrepDriver(ref spec); if (spec.ConfigurableTypes != null) { ICatalogObject obj2 = this.FindApplication(this._appColl, spec); if (obj2 == null) { throw new RegistrationException(Resource.FormatString("Reg_AppNotFoundErr", spec)); } ICatalogCollection collection = (ICatalogCollection) this._appColl.GetCollection(CollectionName.Components, obj2.Key()); string[] arr = new string[spec.ConfigurableTypes.Length]; int index = 0; foreach (Type type in spec.ConfigurableTypes) { arr[index] = Marshal.GenerateGuidForType(type).ToString(); index++; } Populate(collection); bool flag = true; int lIndex = 0; while (lIndex < collection.Count()) { ICatalogObject obj3 = (ICatalogObject) collection.Item(lIndex); string g = (string) obj3.Key(); g = new Guid(g).ToString(); if (this.FindIndexOf(arr, g) != -1) { collection.Remove(lIndex); if (sync != null) { sync.Set(); } } else { lIndex++; flag = false; } } SaveChanges(collection); if (flag) { for (int i = 0; i < this._appColl.Count(); i++) { ICatalogObject obj4 = (ICatalogObject) this._appColl.Item(i); if (obj4.Key().Equals(obj2.Key())) { this._appColl.Remove(i); if (sync != null) { sync.Set(); } break; } } SaveChanges(this._appColl); } } this.UnregisterAssembly(asm, spec); this.CleanupDriver(); } }