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 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; } }