public override void  Unload()
        {
            try
            {
                if (this.domain == null)
                {
                    return;
                }

                if (this.TestEngine != null)
                {
                    this.TestEngine.Clear();
                }
                this.SetTestEngine(null);

                AppDomain.Unload(this.domain);
                this.domain = null;
                if (this.ShadowCopyFiles && this.CachePath != null && Directory.Exists(this.CachePath))
                {
                    CacheFolderHelper.DeleteDir(new DirectoryInfo(this.CachePath));
                }
                this.OnUnLoaded();
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed unloading domain", ex);
            }
        }
        public void Clear()
        {
            this.Unload();
            foreach (TreeTestDomain td in this)
            {
                td.Dispose();
            }

            this.Watcher.Clear();
            this.identifierDomains.Clear();
            this.list.Clear();
            this.pendingStop = false;

            // delete cache folder
            String cachePath = Environment.ExpandEnvironmentVariables("%TEMP%/Cache");

            CacheFolderHelper.DeleteDir(cachePath);
        }
        /// <summary>
        /// Set the location for caching and delete any old cache info
        /// </summary>
        /// <param name="setup">Our domain</param>
        protected void ConfigureCachePath(AppDomainSetup setup)
        {
            try
            {
                this.cachePath = String.Format(@"%TEMP%\Cache\{0:00000000}", DateTime.Now.Ticks);
                this.cachePath = Environment.ExpandEnvironmentVariables(cachePath);
                this.cachePath = Path.GetFullPath(this.cachePath);

                DirectoryInfo dir = new DirectoryInfo(this.cachePath);
                if (dir.Exists)
                {
                    CacheFolderHelper.DeleteDir(dir);
                }
                dir.Create();
                setup.CachePath = cachePath;
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed configurating the Shadow copy path", ex);
            }
        }