[Python.NET] Debugging .NET assembly from Python 3

Denis Akhiyarov denis.akhiyarov at gmail.com
Tue Jul 19 12:10:25 EDT 2016


@ *Pochon-Guérin Ludovic* just to clarify:

to debug C# code called using pythonnet from CPython in PTVS you need to
select ONLY "Managed" debugger engine. By default it selects "Managed +
Python" which does not work. It is possible to get Managed + Native +
CPython mixed- mode debugging working, but this requires additional steps.

If you follow my steps and still experience issues, than please provide me
with a simple reproducible example: C# + Python code.

Note that there should not be any problem with Miniconda/Anaconda/conda
python installation, because it is still CPython interpreter with debugging
symbols provided in the installation. Unless you hijacked it with your
custom CPython build :)




On Thu, Jun 16, 2016 at 8:13 AM, Pochon-Guérin Ludovic <
Ludovic.Pochon-Guerin at statkraft.com> wrote:

> Thank you for your help.
>
>
>
> It is not possible to attach to the Python process the way explained in
> PTVS discussion, because it is greyed.
>
> I think it is because I am already running the python process when
> starting debugger from python file in Visual Studio
>
>
>
> I think my problem is due to the Python environment.
>
> I use Miniconda3 and not CPython interpreter in Visual Studio.
>
> It might be something to do with the CLR module too.
>
>
>
> Unfortunately I don’t have time to investigate further and will have to
> work without debugging for the time being.
>
>
>
> Thanks anyway
>
> Ludovic
>
>
>
>
>
> *From:* PythonDotNet [mailto:pythondotnet-bounces+ludovic.pochon-guerin=
> statkraft.com at python.org] *On Behalf Of *Denis Akhiyarov
> *Sent:* 14. juni 2016 16:49
> *To:* A list for users and developers of Python for .NET
> *Subject:* Re: [Python.NET] Debugging .NET assembly from Python 3
>
>
>
> I regularly debugging C# code called from python side using pythonnet. So
> something is likely wrong in your settings.
>
>
>
> Here is how you set debugger engines (see picture in the comments):
>
> https://github.com/Microsoft/PTVS/issues/674
>
>
>
> This mailing list is super-slowly approved for new messages. You may get
> much faster and better response on PTVS issue tracker:
>
> https://github.com/Microsoft/PTVS/issues/new
>
> Just provide Microsoft Python team with reproducible example. Also mention
> what symbols you see in Debugger "Modules" window.
>
>
>
> If issue is very specific to pythonnet and works on ironpython, then you
> can use pythonnet issue tracker:
>
> https://github.com/pythonnet/pythonnet/issues/new
>
>
>
> Note that PTVS has very specialized code for debugging IronPython, while
> pythonnet debugging happens through CPython debugger.
>
>
>
>
>
> On Tue, Jun 14, 2016 at 4:46 AM, Pochon-Guérin Ludovic <
> Ludovic.Pochon-Guerin at statkraft.com> wrote:
>
> Thank you for your answer,
>
>
>
> I tried all of this without success.
>
>
>
> What do you mean by “select manually managed debugger”?
>
>
>
> Please can you clarify if it is possible to stop at breakpoints in C# code
> when called from Python code (using python dot net)?
>
>
>
> Thanks
>
> Ludovic
>
>
>
>
>
> *From:* PythonDotNet [mailto:pythondotnet-bounces+ludovic.pochon-guerin=
> statkraft.com at python.org] *On Behalf Of *Denis Akhiyarov
> *Sent:* 8. juni 2016 08:32
> *To:* A list for users and developers of Python for .NET
> *Subject:* Re: [Python.NET] Debugging .NET assembly from Python 3
>
>
>
> There are many conversations (both codeplex and github) recorded in issue
> tracker for PTVS about debugging pythonnet code.
>
>
>
> The starting point is to ensure that you are on .NET 4+, select manually
> managed, native, and python debugger engines. Also make sure that managed
> compatibility mode is not selected. Finally make sure that your python
> debug symbols are available to PTVS/VS for cross-language debugging.
>
>
>
> Note that currently the PTVS remote debugger is not working for pythonnet
> when debugging python code.
>
>
>
>
>
> On Tue, Jun 7, 2016 at 3:20 AM, Pochon-Guérin Ludovic <
> Ludovic.Pochon-Guerin at statkraft.com> wrote:
>
> Hi,
>
>
>
> Using Visual Studio 2015, I have a Python project and a C# DLL project.
>
> From the Python code, I import and call functions from the C# class.
>
> When running in Debug, I am able to stop at breakpoints in the Python
> code, but not in the C# code.
>
> The debugger jumps over the calls as if no symbols were loaded.
>
>
>
> I would like to know if it is possible to stop at breakpoints in the C#
> code and how to setup it in Visual Studio.
>
>
>
> This feature works when using IronPython, but we want to use PythonDotNet
> from Miniconda3.
>
>
>
> Thanks
>
> Ludovic
>
>
>
>
>
>
> _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org
> https://mail.python.org/mailman/listinfo/pythondotnet
>
>
>
>
> _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org
> https://mail.python.org/mailman/listinfo/pythondotnet
>
>
>
> _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org
> https://mail.python.org/mailman/listinfo/pythondotnet
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20160719/5e30fcfb/attachment.html>


More information about the PythonDotNet mailing list