我修改了一个 C# 插件,它是 Visual Studio 2.0 的 Python 工具的一部分,并希望在代码中查看 Debug.WriteLine 和 Trace.WriteLine 语句的输出。请注意,该插件用于 Visual Studio 2013 本身,修改 python 进程的调试....
我希望我可以按照 pminaev在此处的 PTVS 讨论论坛上的devenv.exe.config
建议添加一个跟踪侦听器(将另一个 VS 附加到 VS 本身似乎很笨拙,所以我希望避免这种情况)。
我认为其他 .NET 应用程序的正确配置似乎不适用于 VS2013 本身。 我的努力记录在下面。
如果有人设法将插件调试/跟踪输出重定向到 Visual Studio 控制台(或比另一个附加的 VS 实例更方便的任何其他地方),非常感谢提示......
我的 Google-fu 出现了几个示例,基于这些示例我尝试添加...
<system.diagnostics>
<trace autoflush="true" />
<listeners>
<add name="myConsoleTraceListener" type="System.Diagnostics.ConsoleTraceListener" />
</listeners>
</trace>
</system.diagnostics>
...和...
<system.diagnostics>
<source name="System.ServiceModel.MessageLogging" switchValue="Verbose, ActivityTracing">
<listeners>
<add name="myTraceListener" />
</listeners>
</source>
<sharedListeners>
<add name="myTraceListener" type="System.Diagnostics.ConsoleTraceListener" />
</sharedListeners>
</system.diagnostics>
之后启动 PTVS,没有什么可用的。无论使用哪种配置,我都会弹出一个窗口:
The `Python Tools Package' package id not load correctly.
The problem may have been caused by a configuration change or by
the installation of another extension. You can get more information by
examining the file
'C:\Users\XXX\AppData\Roaming\Microsoft\VisualStudio\12.0\Acti
vityLog.xml'.
ActivityLog 对我来说意义不大:
<entry>
<record>41</record>
<time>2014/05/12 07:52:47.851</time>
<type>Error</type>
<source>VisualStudio</source>
<description>CreateInstance failed for package [Python Tools Package]</description>
<guid>{6DBD7C1E-1F1B-496D-AC7C-C55DAE66C783}</guid>
<hr>80131604</hr>
<errorinfo>Exception has been thrown by the target of an invocation.</errorinfo>
</entry>
<entry>
<record>42</record>
<time>2014/05/12 07:52:47.851</time>
<type>Error</type>
<source>VisualStudio</source>
<description>End package load [Python Tools Package]</description>
<guid>{6DBD7C1E-1F1B-496D-AC7C-C55DAE66C783}</guid>
<hr>80004005 - E_FAIL</hr>
<errorinfo>Exception has been thrown by the target of an invocation.</errorinfo>
</entry>
当我尝试附加到远程 python 进程时,我得到另一个弹出窗口:
Unable to connect to 'secret@server'. Operation not supported.
Unknown error: 0x80131902.
Google-foo 建议这是加载 .NET 版本的一些失败......?