[英]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.