Table of Contents

Property ScriptHost

Namespace
Alternet.Scripter.IronPython
Assembly
Alternet.Scripter.IronPython.v9.dll

ScriptHost

Returns object that implements IScriptHost interface for this runner.

[Browsable(false)]
public virtual IScriptHost ScriptHost { get; set; }

Property Value

IScriptHost

Examples

Here is how to use a ScriptHost in the C# code:

using System;

using Alternet.Scripter.IronPython;

public partial class Form1 : Form
{
    private ScriptRun scriptRun;
    private void Form1_Load(object sender, EventArgs e)
    {
        scriptRun = new ScriptRun();
        scriptRun.ScriptHost.ModulesDirectoryPath = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), "Alternet Scripter for IronPython Generated Modules");
        scriptRun.ScriptSource.FromScriptCode(edit.Text);

        if (!scriptRun.Compiled)
        {
            if (!scriptRun.Compile())
            {
                MessageBox.Show(string.Join("\r\n", scriptRun.ScriptHost.CompilerErrors.Select(x => x.ToString()).ToArray()));
                return;
            }
        }
    }
}

Here is how to use a ScriptHost in the Visual Basic code:

Imports System
Imports Alternet.Scripter.IronPython

Partial Public Class Form1
    Inherits Form

    Private scriptRun As ScriptRun

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        scriptRun = New ScriptRun()
        scriptRun.ScriptHost.ModulesDirectoryPath = Path.Combine(Environment.GetEnvironmentVariable("TEMP"), "Alternet Scripter for IronPython Generated Modules")
        scriptRun.ScriptSource.FromScriptCode(edit.Text)

        If Not scriptRun.Compiled Then

            If Not scriptRun.Compile() Then
                MessageBox.Show(String.Join(vbCrLf, scriptRun.ScriptHost.CompilerErrors.[Select](Function(x) x.ToString()).ToArray()))
                Return
            End If
        End If
    End Sub
End Class

Remarks

ScriptHost contains properties and methods related to the Iron-python scripts compilation and execution.

Most of the time you don�t need to use ScriptHost directly, as most of its properties and methods are accessible via ScriptRun.