小编Kae*_*ber的帖子

有什么方法可以使用 Visual Studio 和 PTVS 调试嵌入在 C# 中的 Python 代码?

我已经创建了在 C# 中嵌入 IronPython 代码的代码

    public ScriptEngine GetEngine() {
        if( _engine != null )
            return _engine;

        _engine = Python.CreateEngine();
        var paths = _engine.GetSearchPaths();
        paths.Add( _pythonPath );
        _engine.SetSearchPaths( paths );

        var runtime = _engine.Runtime;
        runtime.LoadAssembly( typeof( CharacterCore ).Assembly );
        return _engine;
    }

    public IAbility Movement() {
        var engine = GetEngine();
        var script = engine.CreateScriptSourceFromFile( Path.Combine( _pythonPath, "movement.py" ) );
        var code = script.Compile();
        var scope = engine.CreateScope();
        code.Execute( scope );

        return scope.GetVariable( "result" );
    }
Run Code Online (Sandbox Code Playgroud)

在同一解决方案中的单独 Python 项目中使用适当的 Python 代码。代码本身有效,但如果我在 Python …

c# debugging ironpython visual-studio ptvs

3
推荐指数
1
解决办法
2847
查看次数

标签 统计

c# ×1

debugging ×1

ironpython ×1

ptvs ×1

visual-studio ×1