コード例 #1
0
        /// <include file='doc\EventLogInstaller.uex' path='docs/doc[@for="EventLogInstaller.Rollback"]/*' />
        /// <devdoc>
        /// Called when this or another component in the installation has failed.
        /// </devdoc>
        public override void Rollback(IDictionary savedState)
        {
            base.Rollback(savedState);

            Context.LogMessage(Res.GetString(Res.RestoringEventLog, Source));

            if (savedState["baseInstalledAndPlatformOK"] != null)
            {
                bool logExists = (bool)savedState["logExists"];
                if (!logExists)
                {
                    EventLog.Delete(Log, ".");
                }
                else
                {
                    bool   alreadyRegistered;
                    object alreadyRegisteredObj = savedState["alreadyRegistered"];
                    if (alreadyRegisteredObj == null)
                    {
                        alreadyRegistered = false;
                    }
                    else
                    {
                        alreadyRegistered = (bool)alreadyRegisteredObj;
                    }

                    if (!alreadyRegistered)
                    {
                        // delete the source we installed, assuming it succeeded. Then put back whatever used to be there.
                        if (EventLog.SourceExists(Source, "."))
                        {
                            EventLog.DeleteEventSource(Source, ".");
                        }
                    }
                }
            }
        }