示例#1
0
文件: Program.cs 项目: cemoses/aspnet
        private Task <int> ExecuteMain(DefaultHost host, string applicationName, string[] args)
        {
            Assembly assembly = null;

            try
            {
                assembly = host.GetEntryPoint(applicationName);
            }
            catch (FileNotFoundException ex) when(new AssemblyName(ex.FileName).Name == applicationName)
            {
                if (ex.InnerException is ICompilationException)
                {
                    throw ex.InnerException;
                }

                ThrowEntryPointNotfoundException(
                    host,
                    applicationName,
                    ex.InnerException);
            }

            if (assembly == null)
            {
                return(Task.FromResult(-1));
            }

            return(EntryPointExecutor.Execute(assembly, args, host.ServiceProvider));
        }
示例#2
0
        private Task <int> ExecuteMain(DefaultHost host, string applicationName, string[] args)
        {
            Assembly assembly = null;

            try
            {
                assembly = host.GetEntryPoint(applicationName);
            }
            // Compilation exceptions either throw FileNotFound or FileLoad exceptions and may change
            // from version to version. It's safest to catch both types of exceptions
            catch (Exception ex) when(ex is FileLoadException || ex is FileNotFoundException)
            {
                if (ex.InnerException is ICompilationException)
                {
                    throw SuppressStackTrace(ex.InnerException);
                }

                ThrowEntryPointNotfoundException(
                    host,
                    applicationName,
                    ex.InnerException);
            }

            if (assembly == null)
            {
                return(Task.FromResult(-1));
            }

            return(EntryPointExecutor.Execute(assembly, args, host.ServiceProvider));
        }
示例#3
0
文件: Program.cs 项目: leloulight/dnx
        private static Task <int> ExecuteMain(DefaultHost host, string applicationName, string[] args)
        {
            Assembly assembly = null;

            try
            {
                assembly = host.GetEntryPoint(applicationName);
            }
            catch (Exception ex)
            {
                SuppressCompilationExceptions(ex);
                if (ex is FileLoadException || ex is FileNotFoundException)
                {
                    ThrowEntryPointNotfoundException(
                        host,
                        applicationName,
                        ex.InnerException);
                }

                throw;
            }

            if (assembly == null)
            {
                return(Task.FromResult(1));
            }

            return(Task.Run(() => EntryPointExecutor.Execute(assembly, args, host.ServiceProvider))
                   .ContinueWith(t =>
            {
                t.Exception?.Handle(e =>
                {
                    SuppressCompilationExceptions(e);
                    return false;
                });

                return t.Result;
            }));
        }