/// <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.InstallAssemblyFromConfig"]/*' /> public void InstallAssemblyFromConfig([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 driver = new RegistrationDriver(); driver.InstallAssembly(regConfig, sync); ContextUtil.SetComplete(); succeed = true; } finally { if (!succeed) { DBG.Info(DBG.Registration, "Install failed."); ContextUtil.SetAbort(); } } }