Our codebase is written mostly in C# with some scripting capabilities using IronPython 3.4. Until recently we based the project on the outdated .Net Framework 4.8 but made the move to .Net 8 recently.
One odd thing is bugging us: With .Net Framework as a target we could load the python script files in Visual Studio and set breakpoints which nicely triggered when the script was executed. After the shift to .Net 8 this does not work any longer.
I created a minimal working example to confirm this behavior:
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Runtime;
using System;
using System.Collections.Generic;
namespace ScriptTest
{
internal class Program
{
static void Main(string[] args) {
ScriptEngine pythonEngine = null;
ScriptScope pythonScope = null;
Dictionary<string, object> options = new Dictionary<string, object>();
options["Debug"] = ScriptingRuntimeHelpers.True;
pythonEngine = Python.CreateEngine(options);
pythonScope = pythonEngine.CreateScope();
ScriptSource pythonSrc = pythonEngine.CreateScriptSourceFromFile(@".\Test.py");
CompiledCode compiled = pythonSrc.Compile();
compiled.Execute(pythonScope);
}
}
}
with the following very simple Test.py file:
print('Test')
One thing I noticed is that with the .Net Framework version a symbol "file" called Snippets.debug.scripting is loaded a soon as the Python script is ececuted. This does not happen in the .Net 8 version.
Any ideas how to get breakpoints working with .Net 8? Maybe this is just some Visual Studio setting but I found not clue yet.
snippets.debug.scripting
file can be loaded with .NET 8. If the file not loaded, please check if you have enabledEnable Just My Code
.