Exemple #1
0
        /// <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();
                }
            }
        }
Exemple #2
0
        /// <include file='doc\RegistrationWrappers.uex' path='docs/doc[@for="RegistrationHelper.UninstallAssemblyFromConfig"]/*' />
        public void UninstallAssemblyFromConfig([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.UninstallAssemblyFromConfig");

            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.UninstallThread));
                t.Start();
                t.Join();
                wrap.PropUninstallResult();
            }
            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.
                if (Platform.IsLessThan(Platform.W2K) || !TryTransactedUninstall(regConfig))
                {
                    // We need to try a non-transacted install:
                    DBG.Info(DBG.Registration, "Failed to do a transacted uninstall.  Using non-tx uninstall.");
                    RegistrationDriver helper = new RegistrationDriver();
                    helper.UninstallAssembly(regConfig, null);
                }
            }
        }