Beispiel #1
0
        /// <summary>
        /// Execute the specified MANAGED application in a new AppDomain.
        ///
        /// The base directory for the new application domain will be set to
        /// directory containing filename (Path.GetDirectoryName(Path.GetFullPath(filename))).
        /// </summary>
        public static string shellm(string filename, params string[] arguments)
        {
            AppDomainSetup setup = new AppDomainSetup();

            setup.ApplicationBase = Path.GetDirectoryName(Path.GetFullPath(filename));

            AppDomain domain = AppDomain.CreateDomain("shellm", null, setup);

            try
            {
                AssemblyExecutor executor = new AssemblyExecutor(filename, arguments);
                domain.DoCallBack(new CrossAppDomainDelegate(executor.Execute));
                return(executor.CapturedOutput);
            }
            finally
            {
                AppDomain.Unload(domain);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Execute the specified MANAGED application in a new AppDomain.
        ///
        /// The base directory for the new application domain will be set to
        /// directory containing filename (Path.GetDirectoryName(Path.GetFullPath(filename))).
        /// </summary>
        public static string shellm(string filename, params string[] arguments)
        {
            AppDomainSetup setup = new AppDomainSetup();
            setup.ApplicationBase = Path.GetDirectoryName(Path.GetFullPath(filename));

            AppDomain domain = AppDomain.CreateDomain("shellm", null, setup);
            try
            {
                AssemblyExecutor executor = new AssemblyExecutor(filename, arguments);
                domain.DoCallBack(new CrossAppDomainDelegate(executor.Execute));
                return executor.CapturedOutput;
            }
            finally
            {
                AppDomain.Unload(domain);
            }
        }