How to get error code line and column for C#/Python ScriptRun run exception

Similar question as this topic.
But I couldn’t find Engine.GetService for Alternet.Scripter.Roslyn.RoslynScriptHost and Alternet.Scripter.Python.ScriptHost.

I also try to use ScriptRun.ScriptError += ScriptRunner_ScriptError, but it didn’t be triggered when exception happened.

private void ScriptRunner_ScriptError(object sender, ScriptErrorEventArgs e)
    var message = string.Join("\r\n", e.Errors.Select(x => x.ToString()).ToArray());

Is there any way to get more information about ScriptRun run exception?

Hi Sara,

ScriptError is only called to report diagnostics during script compilation (such as syntax errors in the script code). Once script is compiled, running it would be the same as running any .NET method.

To handle run-time exceptions, you would need to enclose ScriptRun.Run() or ScriptRun.RunMethod() in try/catch block and examine exception.Source or exception.StackTrace properties to get additional information about the exception.

Let me know if this is what you need.

Kind regards,

Hi Dmitry.

It’s clear, thank you!