简体   繁体   English

如何在调用Visual Studio调试器可视化器之间持久保存自定义对象?

[英]How to persist custom objects between calls to a Visual Studio debugger visualizer?

I need to persist an object between calls to a debugger visualizer I'm writing, but it doesn't need to persist between IDE sessions. 我需要在我正在编写的调试器可视化器的调用之间保留一个对象,但是它不需要在IDE会话之间保留。 The EnvDTE.Globals object for the IDE seemed like an obvious place to store this object. IDE的EnvDTE.Globals对象似乎是存储该对象的明显位置。

If the type of the object being stored is already loaded in the IDE, eg a list of integers, I can successfully save a variable of this type in the globals object, and then retrieve it on a subsequent call to the debugger visualizer. 如果要存储的对象的类型已经在IDE中加载,例如整数列表,则可以成功将这种类型的变量保存在globals对象中,然后在随后对调试器可视化器的调用中检索它。

However, if the type of the variable being saved is declared in the assembly containing the debugger visualizer itself, or in a local assembly referenced by the visualizer, then it all goes horribly wrong. 但是,如果在包含调试器可视化程序本身的程序集中或在可视化程序引用的本地程序集中声明了要保存的变量的类型,则所有操作都将出错。 I can save the object into the globals, and retrieve it within the same call to the visualizer. 我可以将对象保存到全局变量中,并在对可视化工具的同一调用中检索它。 However, when I try to access it in a subsequent call I can successfully test the value exists, but when I try to access it the IDE falls over. 但是,当我尝试在后续调用中访问它时,我可以成功测试该值是否存在,但是当我尝试访问它时,IDE崩溃了。

I presume that what is happening is the assembly for the debugger visualizer is reloading each time the visualizer is used, and so the type of the stored object isn't matching the type I'm expecting. 我认为正在发生的是,每次使用可视化工具时,调试器可视化工具的程序集都会重新加载,因此存储对象的类型与我期望的类型不匹配。 Well, that's my guess. 好吧,那是我的猜测。 Any explanations/workarounds would be appreciated. 任何解释/变通办法,将不胜感激。

您是否尝试过序列化/反序列化对象并存储序列化结果而不是对象?

I wanted to maintain a WCF callback object, and have the remote client be able to call back even when the debugger extension wasn't active. 我想维护一个WCF回调对象,并且使远程客户端即使在调试器扩展未处于活动状态时也能够进行回调。 So storing a serialized version of the object wouldn't help in this particular instance. 因此,存储对象的序列化版本在此特定实例中无济于事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何编写一个非常简单的Visual Studio调试器可视化工具? - How do I write a very simple Visual Studio debugger visualizer? Visual Studio未加载我的调试器可视化工具 - Visual Studio is not loading my debugger visualizer Visual Studio 调试器图形可视化器 C++ - visual studio debugger graphical visualizer c++ 如何使用Visual Studio Text Visualizer进行自定义类型? - How to use Visual Studio Text Visualizer for custom types? Visual Studio调试器如何确定可以使用Text / XML / HTML Visualizer查看哪些值? - How does the Visual Studio debugger decide which values can be viewed with the Text/XML/HTML Visualizer? 如何使用 natvis Visual Studio C++ 调试器可视化工具对单一类型进行多个列表扩展 - How to make multiple list expansions for a single type using natvis Visual Studio C++ debugger visualizer Visual Studio 自定义数据可视化工具抛出 BadImageFormatException - Visual Studio custom data visualizer throws BadImageFormatException 试图让DataRow [] Debugger Visualizer在Visual Studio 2010中工作 - Trying to get a DataRow[] Debugger Visualizer to work in Visual Studio 2010 用于Qt图像类型的Visual Studio 2010调试器可视化工具? - Visual Studio 2010 debugger visualizer for Qt image types? 是否为ASP.NET会话提供了Visual Studio调试器可视化工具? - Is there a Visual Studio debugger visualizer for the ASP.NET Session?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM