views:

460

answers:

2

Are there any in-built or 3rd party libraries that allow you to simply dump all variables in memory during run time? What I would like is to be able to view variables & current values similarly to viewing them by hitting a break point and hovering over variables, but without actually having to halt the program execution (i.e. just get a snapshot). Would be good if it could dump them to a file which can then be opened later in a program to get a nice GUI interface to view them, but simple text file dump would be good enough.

+2  A: 

I believe some sort of logging framework would help you to do that...

Check out:

http://www.dotnetlogging.com/

At my workplace we use log4net which works pretty well for us.

So how come you're wanting to dump out all the variables for later analysis? Have you considered writing your code test first so that you can reduce your reliance on the debugger and have a suite of automated test checking the values for you?

mezoid
Yeah I already use logging similar to log4net. However I wanted more so a generic variable dump so that I wouldn't have to write specific code to dump variables to a logger for every program. It would also be nice to have a GUI viewer of a snapshot so that for complex class structures it is easy to read.
mrnye
I want to dump the variables for peace of mind basically. I'm confident in the program but just want to confirm everything is going OK. It's extremely hard to write thorough tests for the nature of work I am doing, and even then you can only write tests for situations you can think of. It would also be able to form as a low level way to see what state the program is in at any point in time.
mrnye
+2  A: 

I can't think of an easy way to do this in a generic fashion. What could work is programmatically creating a dump file of your running process. You could either do this with P/Invoke to the dbghelp.dll routines or spawn a cdb.exe process to create the dump file. Once you have the file, you could open it up in a debugger for later analysis using SOS.dll with cdb.exe/windbg.exe, or even write a debugger script to dump the data you want (mostly) automatically.

bobbymcr