【发布时间】:2019-04-03 19:35:10
【问题描述】:
我正在开发 asp.net 核心应用程序 + IronPython。 但是我遇到了调试问题...
例如,我有以下代码:
Dictionary<string, object> options = new Dictionary<string, object>();
options["Debug"] = true;
ScriptEngine engine = Python.CreateEngine(options);
// output redirect
var eIO = engine.Runtime.IO;
var errors = new MemoryStream();
eIO.SetErrorOutput(errors, Encoding.Default);
var result = new MemoryStream();
eIO.SetOutput(result, Encoding.Default);
// execute script
ScriptScope scope = engine.CreateScope();
scope.SetVariable("testGlobalVar", 10);
engine.ExecuteFile(ScriptPath, scope);
在python文件中
some = "Test"
print(Test)
print("We have ->", testGlobalVar)
它工作正常,但我不知道如何在 python 文件中设置断点并在通过 C# 运行时在 Visual Studio、Pycharm 中逐步调试它。
我找到了this question,但它几乎完全没用。我在 python 文件中设置断点,没有任何反应。
【问题讨论】:
-
你用的是哪个版本的VS?
-
我正在使用 Visual Studio 2019
-
设置断点后,选择开始调试(F5),有什么反应吗?请在解决方案资源管理器中检查您的 python 环境以确保环境正常。
-
Breakpoints 仅适用于 C# 代码,对于 python,它表示“当前不会命中断点。没有为此文档加载任何符号”。 @LanceLi-MSFT 您可以发送屏幕截图,如何配置所有内容吗?这就是我所拥有的monosnap.com/file/JarPr2hOfdTXqP7oPUoMdjXyAVPRmf
-
你在调试模式下开始调试吗?如果您创建一个新 IronPython 项目,添加断点并对其进行调试,结果会怎样?能成功吗?
标签: c# visual-studio ironpython visual-studio-debugging visual-studio-2019