public void Run(String fileName)
        {
            // Set the source code
            String sourceCode = GetSourceCode(fileName);
            // Find reference
            String reference = GetReference();

            ScriptCompiler compiler = new ScriptCompiler();

            CompilerResults results;
            results = compiler.CompileScript(sourceCode, reference);

            if (results.Errors.Count == 0)
            {
                IScript _compiledScript = (IScript)compiler.FindInterface(results.CompiledAssembly, "IScript");
                _compiledScript.Main(); // Run the transcript

            }
            else
            {
                MessageBox.Show("Compile failed with " + results.Errors.Count.ToString() + " errors.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
        private void btnCompile_Click(object sender, EventArgs e)
        {
            CompilerResults results;

            Cursor = Cursors.WaitCursor;

            // Find reference
            String reference = GetReference();

            // Compile script
            lvwErrors.Items.Clear();
            ScriptCompiler m_Compiler = new ScriptCompiler();
            //results = Scripting.CompileScript(ScriptSource, reference, Scripting.Languages.VB);
            results = m_Compiler.CompileScript(ScriptSource, reference);

            if (results.Errors.Count == 0)
            {
                MessageBox.Show("Compile successfully");
            }
            else
            {
                ListViewItem l;

                // Add each error as a listview item with its line number
                foreach (CompilerError err in results.Errors)
                {
                    l = new ListViewItem(err.ErrorText);
                    l.SubItems.Add(err.Line.ToString());
                    lvwErrors.Items.Add(l);
                }

                MessageBox.Show("Compile failed with " + results.Errors.Count.ToString() + " errors.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }

            Cursor = Cursors.Default;
        }
        private void btnRun_Click(object sender, EventArgs e)
        {
            // Find reference
            String reference = GetReference();

            ScriptCompiler compiler = new ScriptCompiler();

            CompilerResults results;
            results = compiler.CompileScript(ScriptSource, reference);

            if (results.Errors.Count == 0)
            {
                IScript _compiledScript = (IScript)compiler.FindInterface(results.CompiledAssembly, "IScript");
                if (_compiledScript != null)
                    _compiledScript.Main(); // Run the transcript
                else
                    MessageBox.Show("No script");

            }
            else
            {
                MessageBox.Show("Compile failed with " + results.Errors.Count.ToString() + " errors.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }