I embedded a python script in an asp.net core 2.1 project with IronPython.
My python script foo.py:
class Calculator:
def add(self, argA, argB):
return argA+argB
My C# method to call foo.py:
using IronPython.Hosting;
using System;
using System.Collections.Generic;
namespace PythonCore.Models
{
public class PythonCaller
{
public void callPython()
{
Dictionary<string, object> options = new Dictionary<string, object>();
options["Debug"] = true;
var engine = Python.CreateEngine(options);
dynamic py = engine.ExecuteFile(@"PATHTOfoo\foo.py");
dynamic calc = py.Calculator();
double a = 7.5;
double b = 2.5;
double res;
res = calc.add(a, b);
Console.WriteLine("{0} + {1} = {2}", a, b, res);
}
}
}
The code works fine but now I want to debug the python script. As you can see I tried this solution: Debugging IronPython scripts in hosted (embedded) environment I also included Python (next to "native") to types that are being debugged (Debugging -> attach to Process). But it does not work for me? The breakpoint says it's "not reachable".
Did I forget something?
Take a look at the second solution from this link
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.