Ironpython Integration With C#/ .net
So I'm trying to develop this application that will get a captcha image from an website and try to decode it so I can fill the captcha input text with the resulted text after I dec
Solution 1:
You can create a function to run your IronPythonScript and catch and re-raise exceptions that tell you what line of code is problematic as follows:
publicstaticdynamicRunIronPythonScript(string fileName)
{
var ipy = IronPython.Hosting.Python.CreateRuntime();
try
{
dynamic test = ipy.ExecuteFile(fileName);
return test;
}
catch (Exception e)
{
var engine = IronPython.Hosting.Python.GetEngine(ipy);
ExceptionOperations eo = engine.GetService<ExceptionOperations>();
string error = eo.FormatException(e);
thrownew Exception(error);
}
}
Then you can call it as follows:
staticvoidMain(string[] args)
{
RunIronPythonScript("crack.py");
}
This will at least show you which line of code is causing the error, making it easier to fix the script up.
Solution 2:
Try:
Microsoft.Scripting.Hosting.ScriptEngineengine=
IronPython.Hosting.Python.CreateEngine();
engine.ExecuteFile("crack.py");
Post a Comment for "Ironpython Integration With C#/ .net"