The following code, after execution, no result
Support for. Net5, in the release description, I chose netcoreapp3.1
Support for. Net5, in the release description, I chose netcoreapp3.1
C# code:
// script "ipy_code3.cs" /*/ r Libraries\IronPython.dll; r Libraries\Microsoft.Scripting.dll; r Libraries\Microsoft.Dynamic.dll; /*/ //.
using Au; using System; using Microsoft.Scripting.Hosting;
using IronPython.Hosting;
using System.Collections.Generic;
using System.Linq;
partial class Script : AScript { [STAThread] static void Main(string[] a) => new Script(a); Script(string[] args) { //;;;
AOutput.RedirectConsoleOutput=true;
ScriptEngine engine = Python.CreateEngine();
ScriptSource source = engine.CreateScriptSourceFromFile(@"C:\Users\Administrator\Desktop\script.py");
ScriptScope scope = engine.CreateScope();
ObjectOperations op = engine.Operations;
source.Execute(scope); // class object created
object classObject = scope.GetVariable("MyClass"); // get the class object
object instance = op.Invoke(classObject); // create the instance
object method = op.GetMember(instance, "myMethod"); // get a method
List<string> result = ((IList<object>)op.Invoke(method)).Cast<string>().ToList();
Console.WriteLine(result.ToString());
Console.Read();
}
}