• HOME
  • PRODUCTS
  • DEMOS
  • BUY
  • BLOG
  • FORUM
  • DOCUMENTATION
  • ABOUT
  • FREE EVALUATION
Search Results for

    Show / Hide Table of Contents

    ScriptRun Class

    Definition

    Namespace: Alternet.Scripter
    Assembly: Alternet.Scripter.v8.dll

    Represents runner for script engine.

    Inheritance
    Object
    MarshalByRefObject
    Component
    ScriptRun
    Implements
    IComponent
    IDisposable
    IScriptRun
    IScriptRunBase
    Syntax
    [ToolboxBitmap(typeof(ScriptRun), "Images.ScriptRun.Icon.bmp")]
    public class ScriptRun : Component, IComponent, IDisposable, IScriptRun, IScriptRunBase

    Remarks

    ScriptRun is a non-visual component that allows executing C# or Visual Basic scripts and script projects with forms and resources; it allows referencing third-party assemblies and registering application-defined objects to be accessible in the scripts.

    The most important properties and methods of the ScriptRun are:

    The ScriptHost property provides properties and methods of the underlying scripting engine.

    The ScriptSource property contains the source of the script to execute.

    The GlobalItems property contains a collection of application objects accessible to the scripts.

    The ScriptLanguage property represents the programming language of the script.

    The Run() method executes the script.

    The RunMethod method executes the specified script method.

    Examples

    Here is how to run C# script using ScriptRun from the C# code:

    public partial class Form1 : Form
    {
        private void Form1_Load(object sender, EventArgs e)
        {
            var scriptRun = new Alternet.Scripter.ScriptRun();
            scriptRun.ScriptMode = Alternet.Scripter.ScriptMode.Debug;
            scriptRun.ScriptSource.FromScriptFile(@"c:\myscript.cs");
            scriptRun.ScriptSource.WithDefaultReferences();
            scriptRun.AssemblyKind = ScriptAssemblyKind.DynamicLibrary;
            scriptRun.Run();
        }
    }
    

    Here is how to run C# script using ScriptRun from the Visual Basic code:

    Partial Public Class Form1
        Inherits Form
    
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
            Dim scriptRun = New Alternet.Scripter.ScriptRun()
            scriptRun.ScriptMode = Alternet.Scripter.ScriptMode.Debug
            scriptRun.ScriptSource.FromScriptFile("c:\myscript.cs")
            scriptRun.ScriptSource.WithDefaultReferences()
            scriptRun.AssemblyKind = ScriptAssemblyKind.DynamicLibrary
            scriptRun.Run()
        End Sub
    End Class
    

    Constructors

    ScriptRun()

    Initializes a new instance of the ScriptRun class with default settings.

    ScriptRun(IContainer)

    Initializes a new instance of the ScriptRun class with specified parameters.

    Properties

    AssemblyKind

    Gets or sets output kind for the script assembly.

    CaseSensitive

    Indicates whether script language is case sensitive.

    Compiled

    Gets boolean value indicating that script has been compiled and ready to be executed.

    Executed

    Gets boolean value indicating that script has been compiled and ready to be executed.

    GlobalItems

    Gets or sets a script items collection attached to this runner.

    Platform

    Gets or sets target platform (32 or 64 bits).

    ScriptHost

    Returns object that implements IScriptHost interface for this runner.

    ScriptLanguage

    Gets or sets programming language of the script.

    ScriptMode

    Gets or sets debug or release mode for the scripts being executed.

    ScriptSource

    Gets source of the script to execute.

    TargetFrameworkVersion

    Gets or sets target framework version for locating Framework assemblies.

    Win32ManifestOptions

    Gets or sets Win32 manifest options for the script assembly.

    Methods

    Compile()

    Initializes script engine and compiles the script.

    CreateScriptHost()

    Creates a new IScriptHost object with appropriate characteristics.

    CreateScriptSource()
    Dispose(Boolean)
    EvaluateExpression(String)

    Evaluates specified expression.

    EvaluateExpressionAsync(String, CancellationToken)

    Evaluates specified expression asynchronously.

    LoadFile(String)

    When implemented by a class, load text content from the specified file.

    LoadScript(String)

    Load script from specified file.

    OnFileLoad(String)

    Invokes FileLoad event handler.

    OnResolveReference(String, out String, out Byte[])

    Invokes ReferenceResolve event handler.

    OnScriptCompiled()

    Invokes ScriptCompiled event handler.

    OnScriptError(ScriptErrorEventArgs)

    Invokes ScriptError event handler.

    OnScriptExecuted()

    Invokes ScriptRunning event handler.

    OnScriptReset()

    Invokes ScriptReset event handler.

    OnScriptRunning()

    Invokes ScriptRunning event handler.

    Reset()

    Resets the script engine and releases all resources.

    Run()

    Executes script starting from the main entry point.

    Run(String[])

    Executes script starting from the main entry point.

    RunAsync(String[], CancellationToken)

    Executes script asynchronously starting from the main entry point.

    RunMethod(String, Object, Object[])

    Executes specified method.

    RunMethodAsync(String, Object, Object[], CancellationToken)

    Executes specified method asynchronously.

    RunProcess(String[], Boolean)

    Executes script starting from the main entry point in stand-alone process

    Events

    FileLoad

    Occurs when script code is loaded from file.

    ReferenceResolve

    Occurs when assembly reference needs to be resolved.

    ScriptCompiled

    Occurs when the script engine running successfully.

    ScriptError

    Occurs when the script engine running is failed.

    ScriptExecuted

    Occurs when script engine executes the script.

    ScriptReset

    Occurs when the script engine is reset.

    ScriptRunning

    Occurs when script engine tries to running script.

    Explicit Interface Implementations

    IScriptRunBase.ScriptSource
    Inherited Members
    Component.Dispose()
    Component.GetService(Type)
    Component.ToString()
    Component.CanRaiseEvents
    Component.Events
    Component.Site
    Component.Container
    Component.DesignMode
    Component.Disposed
    MarshalByRefObject.MemberwiseClone(Boolean)
    MarshalByRefObject.GetLifetimeService()
    MarshalByRefObject.InitializeLifetimeService()
    MarshalByRefObject.CreateObjRef(Type)
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()

    Implements

    System.ComponentModel.IComponent
    System.IDisposable
    IScriptRun
    IScriptRunBase
    In This Article
    Back to top Copyright AlterNET Software Download PDF