c# – 使用PTVS进行IronPython远程调试
我在C#-Application中成功实现了Iron
Python.我将所有脚本存储在数据库中,并在需要时加载它们.现在我想用PTVS调试我的Python代码.但总是当我尝试连接远程调试器到我的应用程序时,visual studio说我应该使用ptvsd.enable_attach().
>我想如果我启用我的Python-Engine的调试模式,它将是应该的 我无法弄清楚这一点,并尝试了很多,但没有任何真正的工作. 编辑: //copied from: C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDEExtensionsMicrosoftPython Tools for Visual Studio2.0 string dir = Path.GetDirectoryName("C:SupportModulesptvsd"); ICollection<string> paths = myScriptEngine.GetSearchPaths(); if (dir != null && dir != "") { paths.Add(dir); } else { paths.Add(Environment.CurrentDirectory); } 但是现在我在os.py中遇到错误:
在行中: _copy_reg.pickle(statvfs_result,_pickle_statvfs_result,_make_statvfs_result) 编辑2:似乎我可以忽略带有全局名称的错误消息.
编辑3:我使用以下代码解决了跟踪和帧的错误: Dictionary<string,object> options = new Dictionary<string,object>(); options["Debug"] = true; options["Tracing"] = true; options["Frames"] = true; myScriptEngine = Python.CreateEngine(options); 但现在我有下一个问题,我无法将visual studio附加到我的应用程序,我总是得到以下错误消息:
编辑4: # ----------------------------------------------- # Framework-Root-Script # This script is the main-framework script # Autor: BE # Date: 07.10.2013 # ----------------------------------------------- # -------------------------------------------- import sys #import atexit import ptvsd ptvsd.enable_attach(None) #ptvsd.wait_for_attach() # 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 # -------------------------------------------- # -------------------------------------------- #<summary> #Eine Instanz dieser Klasse wird automatisch mit #dem Start des DocCenter Studios erstellt. #</summary> class StudioInstance: # -------------------------------------------- # Declarations # -------------------------------------------- # -------------------------------------------- # Constructor def __init__(self): pass # -------------------------------------------- # -------------------------------------------- # Will be called before the Login-Window open def BeforeUserLogin(self): try: pass except: pass # -------------------------------------------- # -------------------------------------------- #<summary> #Wird ausgeführt,wenn der Login für einen Benutzer # Fehlschl?gt #</summary> #<param Name="InputUserName">Eingegeber Benutzername</param> #<param Name="InputDomain">Eingegebene Domain<param> def LoginFailed(self,InputUserName,InputDomain): try: pass except: pass # -------------------------------------------- # -------------------------------------------- # Will be called if the Login-Process is complete def LoginComplete(self,UserName,Domain): try: # ------------------------------------------------------------------- # Control auf das Tray-Icon setzten (Linksklick) # Mask = DynamicMaskManager.Singleton.GetMaskInstance("Win_DCC_Bediener",False) # grid = Grid() # grid.Children.Add(Mask.VisualElement) # TaskbarNotificationManager.Singleton.AddTrayPopupControl(grid) # ------------------------------------------------------------------- # ------------------------------------------------------------------- # Context-Menu einttrag auf das Tray-Icon setzten # test = MenuItem() # test.Header = "Hallo Welt" # TaskbarNotificationManager.Singleton.AddContextMenuItem(test) # ------------------------------------------------------------------- pass except Exception,e: MessageBox.Show(e.ToString()) # -------------------------------------------- # -------------------------------------------- # Will be called synchron with the UI (same thread) def SyncUpdate(self): try: pass except Exception,e: MessageBox.Show(e.ToString()) # -------------------------------------------- # -------------------------------------------- # Will be called in a custom thread def AsyncUpdate(self): try: pass except: pass # -------------------------------------------- # -------------------------------------------- 编辑5 刷新按钮: 也许有人可以打扰我,谢谢! 解决方法
假设进程在localhost上运行并且您调用了ptvsd.enable_attach(),则可能是防火墙问题.您可能必须调整Windows防火墙以允许连接到该端口(我认为始终允许localhost连接,但我不确定).
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |