views:

68

answers:

3

I have a basic messaging application that takes requests from clients and returns them response objects. When I encounter a malformed request object I serialize it to a database log for failed requests in a binary field. I'd like to be able to deserialize these malformed request objects and inspect them after the fact.

Is there a way to use the Visual Studio Watch window (or something like it) in my own app? I'm aware of the property grid and that's what I'm using for now but it'd be cool to use the watch window to inspect the objects since the watch window is what most of the developers are familiar with.

+1  A: 

How about using Visual Studio itself? You already know how to serialize (and so I presume deserialize) the object. Why not write an app to deserialize it and then hook up the VS debugger to that app?

Moron
Good suggestion, but I don't think that's really usable. There are other parts to the application besides this one and having to hook up the debugger makes it a good deal less sexy.
Jason Punyon
A: 

I would use the PropertyGrid control. It can be used to inspect a single object at a time.

Foole
A: 

What is it that you prefer in the Watch Window over the property grid? Is it the ability to evaluate custom expression, or just it's UI?

If it is the former, then,

I don't know anything out of the box that will let you do this, the thing that comes the closest (without attaching a debugger) is Crack.NET (see this picture), and you could theoretically incorporate that script window into your own project (it's open source, after all), but then you'd have to write your expressions in Python, not C#.

As for a more do-it-yourself approach, you could use CodeDom to compile your expression into a method that looks like:

object Evaluate(RequestObject request)
{
     return   ... your expression goes here ... ;
}

And then load the DLL you have automatically compiled to dynamically call this method, and then present its return value in the property grid if you like.

Omer Raviv