Confused by the name? Let me explain: I am running a python script in a .NET process (my C # application is the host) using IronPython:
ScriptEngine python = Python.CreateEngine(); ScriptSource pyFromFileSource = python.CreateScriptSourceFromString(script); CompiledCode pyFromFileCode = pyFromFileSource.Compile(); ScriptRuntime runtime = engine.Runtime; ScriptScope scope = runtime.CreateScope(); //get a scope where we put in the stuff from the host scope.SetVariable("lab", this); //allow usage of this class in the script script.Execute(scope);
The code shown above runs in the background thread (using the Task class). The script contains an error causing the IronPython.Runtime.Exceptionis.TypeErrorException bubble. I can catch this and get a message.
But how to get the line or line number of the script that throws the exception?
Marcel
source share