I have successfully implemented IronPython in my C # -Application. I save all my scripts in a database and load them when they are needed. Now I want to debug my Python code with PTVS. But always, when I try to connect to a remote debugger with my application, visual studio says what I should use ptvsd.enable_attach().
- I thought that if I turn on Debug mode for my Python-Engine, that would be enough.
- If I need to import ptvsd, how can I import scripts ( ini , main , ...), should I put them also in my database?
I can’t figure it out and tried a lot, but nothing works.
EDIT : I could figure out how to use ptvsd, I have to "enable" the ptvsd module:
string dir = Path.GetDirectoryName("C:\\Support\\Modules\\ptvsd");
ICollection<string> paths = myScriptEngine.GetSearchPaths();
if (dir != null && dir != "")
{
paths.Add(dir);
}
else
{
paths.Add(Environment.CurrentDirectory);
}
But now I get an error message in os.py:
global name statvfs_result not defined
in lines:
_copy_reg.pickle(statvfs_result, _pickle_statvfs_result,
_make_statvfs_result)
EDIT 2 . It seems I can ignore the error message with a global name. But now I get the following message:
IronPython must be started with the -X: Tracing and -X: Frames options to support remote PTVS debugging.
EDIT 3 : I solved the error with trace and frames using the following code:
Dictionary<string, object> options = new Dictionary<string, object>();
options["Debug"] = true;
options["Tracing"] = true;
options["Frames"] = true;
myScriptEngine = Python.CreateEngine(options);
But now I have the following problem: I can’t connect the visual studio to my application, I always get the following error message:
Python "localhost: 5678". , ptvsd.enable_attach() -
4:
python:
import sys
import ptvsd
ptvsd.enable_attach(None)
from System import *
from System.Windows import MessageBox
from System.Windows.Controls import Grid, MenuItem
from ESS.MS.Base import GlobalSettings
from ESS.MS.Framework.Core.TaskbarNotification import TaskbarNotificationManager
from ESS.MS.Framework.UIG.Mask import DynamicMaskManager
class StudioInstance:
def __init__(self):
pass
def BeforeUserLogin(self):
try:
pass
except:
pass
def LoginFailed(self, InputUserName, InputDomain):
try:
pass
except:
pass
def LoginComplete(self, UserName, Domain):
try:
pass
except Exception, e:
MessageBox.Show(e.ToString())
def SyncUpdate(self):
try:
pass
except Exception, e:
MessageBox.Show(e.ToString())
def AsyncUpdate(self):
try:
pass
except:
pass
5
, . , .
Refresh-Button:

- , !