views:

41

answers:

2

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. The EnvDTE.Globals object for the IDE seemed like an obvious place to store this object.

If the type of the object being stored is already loaded in the IDE, e.g. 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.

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.

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.

A: 

Have you tried to serialize/de serialize the object and store the serialization result instead of the object?

Shay Erlichmen
A: 

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. So storing a serialized version of the object wouldn't help in this particular instance.

KM