public void ExecuteVBScript(System.String scriptFile, System.String[] args) { Random randomValue = new Random(); // Create a new script host in which the script will run DvtkScriptHost scriptHost = new DvtkScriptHost( DvtkScriptSupport.DvtkScriptLanguage.VB, "dvtk://session/"+randomValue.Next().ToString(), System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase); // Create the event hanlder for handling the compiler error messages DvtkScriptSupport.CompilerErrorEventHandler compilerEventHandler = new CompilerErrorEventHandler(scriptHostCompilerErrorEvent); scriptHost.CompilerErrorEvent += compilerEventHandler; // Set the current active session in the script host scriptHost.Session = new Dvtk.Sessions.ScriptSession(); // Assign the script content to the script host. scriptHost.SourceCode = ScriptContent(scriptFile); // Compile the script if (scriptHost.Compile()) { // Run the script scriptHost.Invoke("DvtkIheScript", "DvtIheMain", args); } // Remove the event hanlder for handling the compiler error messages scriptHost.CompilerErrorEvent -= compilerEventHandler; }
private void ExecuteHostScript(DvtkScriptHost script_host) { DvtkScriptSupport.CompilerErrorEventHandler compiler_event_handler; // Create the event hanlder for handling the compiler error messages compiler_event_handler = new CompilerErrorEventHandler(script_host_CompilerErrorEvent); script_host.CompilerErrorEvent += compiler_event_handler; // Set the current active session in the script host script_host.Session = (Dvtk.Sessions.ScriptSession)this.selected_session; // Assign the script content to the script host. script_host.SourceCode = this.ScriptContent (this.selected_script); // Compile the script if (script_host.Compile ()) { // Run the script script_host.Invoke ("DvtkScript", "Main", null); } // Notify the root process that the script has finished executing this.RunningProcessEvent (this, null); // Remove the event hanlder for handling the compiler error messages script_host.CompilerErrorEvent -= compiler_event_handler; }