C# 插件:如何在调试时访问对象的运行时实例?
我正在开发一个 C# 插件,仅在调试期间使用。实例化后,我的外接程序需要查找特定类或接口的所有实例,以显示有关找到的数据的图表。
我到底如何在我的扩展中找到或访问这些对象?我可以访问扩展中的 DTE2 应用程序对象,但我不确定如何搜索 VS 正在调试的实际代码。我想我也许能够以某种方式使用反射,但我不知道该去哪里寻找。
谢谢。
I am developing an add in for C# that would only be used during debugging. Once instantiated, my add in needs to find all instances of a specific class or interface to display a graph about the data found.
How exactly can I find or access these objects in my extension? I have access to the DTE2 application object in my extension, but I'm not sure how to search the actual code being debugged by VS. I'm thinking I might somehow be able to use Reflection, but I'm not sure where to look.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经实现了一个插件,可以搜索给定目录中的 dll,并查找实现特定接口的类。下面是我用来执行此操作的类:
您所要做的就是使用如下内容初始化此类:
I've implemented a plugin that searches through dlls in a given directory and finds classes that implement a particular interface. Below is the class I used to do this:
All you have to do is initialize this class with something like this:
从Visual Studio插件中,这种类型的操作实际上是不可能的。当您的加载项在Visual Studio过程中运行时,在Debugee过程中进行调试时,对象还活着。不可能通过.NET中的过程边界访问任意对象。
This type of operation isn't really possible from a Visual Studio plugin. The object alive when debugging live in the debugee process while your add-in is running in the Visual Studio process. It's not possible to access arbitrary objects across process boundaries in .Net.