0

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?

smaica
  • 723
  • 2
  • 11
  • 26

1 Answers1

0

Take a look at the second solution from this link

https://medium.com/emoney-engineering/running-python-script-from-c-and-working-with-the-results-843e68d230e5

Anthony
  • 11
  • 1