Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there some way to save objects to disk in Visual Studio 2012?

I'm hunting for a bug, and it would be really helpful if I could dump the contents of the objects my Locals Window to a file so that I could compare it in Notepad++ with another object record that works correctly. The problem is this: we are not sure if there is a bug in code or a discrepancy in the record.

Is there some way to save a object/variable to disk?

I found this extension, but sadly it is only for VS 2010, and I have 2012.

like image 299
northben Avatar asked Apr 16 '13 20:04

northben


People also ask

How do I save a File in Visual Studio?

From the File menu, choose Save File As, and then click the drop-down button next to the Save button.

How do I save code in Visual Studio?

By default, VS Code requires an explicit action to save your changes to disk, Ctrl+S.

How data is stored in Visual Basic?

You can use serialization to persist an object's data between instances, which enables you to store values and retrieve them the next time that the object is instantiated. In Visual Basic, to store simple data, such as a name or number, you can use the My. Settings object.

Where are Visual Studio projects saved?

In the Documents folder you'll find another one called Visual Studio, followed by a year. In this folder there will be one called Projects. Your work is saved in this folder. In the 2019 version, you may have to create your own folder structure.


2 Answers

You could use the ObjectDumper extension. It's also available as a NuGet package.

like image 129
Dan Avatar answered Oct 06 '22 11:10

Dan


I'm a bit late to the party but I created a Visual Studio extension called Object Exporter that does exactly what you're looking for. It will export any object in your debugging windows (currently only limited to the locals window) to JSON, XML or CSharp object initialization code.

Here's the extension: Visual Studio Marketplace > Object Explorer

And here's an accompanying blog post: Exporting Objects from the Visual Studio Debugger

like image 44
Omar Elabd Avatar answered Oct 06 '22 10:10

Omar Elabd