Paste XML as Classes Missing In Visual Studio

Just wanted to pass along a quick tip for working with the Paste Special features in Visual Studio.  You may be aware that Visual Studio has options for generating classes based on XML and JSON under the Edit, Paste Special menu.

Paste Special

The Paste Special menu and options in Visual Studio 2013.

These options will generate VB.NET or C# classes that work with the built-in .NET serialization libraries.  However, you may only see the option to “Paste JSON as Classes” from the menu in your Visual Studio window.  This is because XML option is only available in projects targeting .NET Framework 4.5 and above.  Change your project’s target framework version and the option will become available.

If you are not able to upgrade your project, you could always create a new .NET 4.5 project, generate the classes there and then copy them to the destination.  You may need to correct some version specific errors, but this option will still get you most of the way there.

Advertisements