示例#1
0
        private Assembly CompileManagerAssembly()
        {
            CompilerResults results = null;
            CompilerParameters parameters = new CompilerParameters(new String[] { "System.dll", "System.Core.dll", "System.Windows.Forms.dll",
                Assembly.GetExecutingAssembly().Location});

            parameters.GenerateInMemory = true;
            parameters.TempFiles = new TempFileCollection(currentProcessDirectory.FullName, false);

            using (CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp"))
            {
                results = provider.CompileAssemblyFromSource(parameters, File.ReadAllText(Path.Combine(currentProcessDirectory.FullName, "SgiManager.cs")));
            }

            if (results != null && results.Errors.Count > 0)
            {
                String message = String.Empty;

                foreach (String str in results.Output)
                    message += str + Environment.NewLine;

                using (ErrorForm errorForm = new ErrorForm(message))
                {
                    errorForm.ShowInTaskbar = true;
                    errorForm.ShowDialog();
                }

                return null;
            }

            return results.CompiledAssembly;
        }
示例#2
0
        private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                toolStripProgressBar.Value = 0;
                toolStripStatusLabel.Text = Resources.CanceledMessage;
            }
            else if (e.Error != null)
            {
                String message = e.Error.Message + Environment.NewLine;

                if (e.Error.InnerException != null)
                    message += e.Error.InnerException.Message + Environment.NewLine;
                message += Environment.NewLine + Resources.StackTraceMessage + Environment.NewLine + e.Error.StackTrace + Environment.NewLine;
                if (e.Error.InnerException != null)
                    message += Environment.NewLine + Resources.BackgroundThreadStackTraceMessage + Environment.NewLine + e.Error.InnerException.StackTrace + Environment.NewLine;

                using (ErrorForm errorForm = new ErrorForm(message))
                {
                    errorForm.ShowDialog();
                }

                toolStripStatusLabel.Text = Resources.ErrorMessage;
            }
            else
                toolStripStatusLabel.Text = Resources.DoneMessage;

            isInstalling = false;
            SetInstallButtonState();
            SetControlsState(true);
            worker.Dispose();
        }