■ AppDomain 클래스 : 애플리케이션 그림자 복사(Shadow Copy) 사용하기

------------------------------------------------------------------------------------------------------------------------


TestSolution.zip


[TestLoader 프로젝트]


Program.cs

 

 

using System;

using System.IO;

 

namespace TestLoader

{

    /// <summary>

    /// 프로그램

    /// </summary>

    class Program

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method

        ////////////////////////////////////////////////////////////////////////////////////////// Static

        //////////////////////////////////////////////////////////////////////////////// Private

 

        #region 프로그램 시작하기 - Main()

 

        /// <summary>

        /// 프로그램 시작하기

        /// </summary>

        [LoaderOptimization(LoaderOptimization.MultiDomainHost)]

        [STAThread]

        private static void Main()

        {

            string applicationDirectoryPath = @"D:\TestSolution\TestProject\bin\Debug";

            string cacheDirectoryPath       = Path.Combine(applicationDirectoryPath, "__cache");

            string configurationFilePath    = Path.Combine(applicationDirectoryPath, "TestProject.exe.config");

 

            string assemblyFilePath = Path.Combine(applicationDirectoryPath, "TestProject.exe");

 

            AppDomainSetup setup = new AppDomainSetup();

 

            setup.ApplicationName   = "TestProject";

            setup.ShadowCopyFiles   = "true";

            setup.CachePath         = cacheDirectoryPath;

            setup.ConfigurationFile = configurationFilePath;

 

            AppDomain appDomain = AppDomain.CreateDomain("TestProject", AppDomain.CurrentDomain.Evidence, setup);

 

            appDomain.ExecuteAssembly(assemblyFilePath);

 

            AppDomain.Unload(appDomain);

 

            Directory.Delete(cacheDirectoryPath, true);

        }

 

        #endregion

    }

}

 

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요