Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio how to serialize object from debugger

I'm trying to investigate a bug in a crash dump (so I can not change the code). I have a really complicated object (thousands of lines in the serialized representation) and its state is inconsistent. To investigate its state the Visual Studio debugger view is useless. But the object has a data contract. I'd like to serialize it and then use my favorite text editor to navigate across the object. Is it possible to do the from the debugger?

like image 442
xvorsx Avatar asked Sep 13 '13 19:09

xvorsx


People also ask

How do I Debug COM objects in Visual Studio?

In visual studio if you open tools >> Options and then debugging >> General make sure the option "Use managed compatibility mode" it checked on. This should show com objects as their proper types in the debugger.

How do I move the Debug pointer in Visual Studio?

The yellow arrow(debug pointer) which can be used to manipulate executing line(or execution flow) while debugging, thus allowing the user to move the arrow simply by using mouse. But it(debug pointer) can't be manipulated or moved using mouse, to change the executing line(or execution flow) while debugging.


1 Answers

With any luck you have Json.Net in you appdomain already. In which case pop this into your Immediate window:

Newtonsoft.Json.JsonConvert.SerializeObject(someVariable)

like image 180
mcintyre321 Avatar answered Sep 20 '22 16:09

mcintyre321