Visual Studio - dump data during a debug session

Depending on a scenario simply paste the code below into the Immediate Window

If you happen to use Newtonsoft.Json:

System.IO.File.WriteAllText(@"c:\temp\debug_dump.json", Newtonsoft.Json.JsonConvert.SerializeObject(obj))

No json serializer? Try xml serializer then:

(new System.Xml.Serialization.XmlSerializer(obj.GetType())).Serialize(new System.IO.StreamWriter(@"c:\temp\debug_dump.xml"), obj)

Obviously the above will throw if an object is not serializable

The Entity Framework provider type 'Npgsql.NpgsqlServices, EntityFramework6.Npgsql' registered in the application config file for the ADO.NET provider with invariant name 'Npgsql' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application

Just wasted way too much time for this:

The Entity Framework provider type 'Npgsql.NpgsqlServices, EntityFramework6.Npgsql' registered in the application config file for the ADO.NET provider with invariant name 'Npgsql' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

Obvious perhaps, but not so much anymore while being sure EntityFramework6.Npgsql has been installed... My project used to work a while ago and I could swear I had all the refs intact. After all it would not work otherwise, right...

Anyway, apart from making sure DbProviderFactories and providers are configured, just dbl check EntityFramework6.Npgsql is actually installed / output. If not reinstalling from nuget is a good start. Did work for me ;)

OGC xml schemas to c# classes using xsd.exe

The process of generating c# classes off the xsd is usually rather simple. One needs the xsd.exe utility (for example located here: C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools) and then a simple command to get things done:

xsd schema.xsd /c

Sometimes there may be some problems though with missing refs, namespaces and such.

In this example, I will generate classes for WMS 1.3.0 based on the OGC schemas - it is possible to grab them one by one, or all the goodies wrapped as a zip archive.

I have extracted WMS 1.3.0 schemas to f:\wms\schemas, so my command should look like this when in f:\wms (I have copied xsd.exe there too):

xsd schemas\capabilities_1_3_0.xsd /c

Unfortunately there are some problems and classes do not get generated:

The problem here is caused by unresolved references. Xsd was not able to find xlink.xsd. Although there is a xlink schema in OGC repo, this is not the one we're after. The one in question is the mentioned http://www.w3.org/1999/xlink, and its schema definition is http://www.w3.org/1999/xlink.xsd, pretty much as defined in the very beginning of the capabilities_1_3_0.xsd I am trying to process:

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.opengis.net/wms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:wms="http://www.opengis.net/wms" xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" version="1.3.0.2">
	
	<!--
		WMS is an OGC Standard.
		Copyright (c) 2004,2010 Open Geospatial Consortium.
		To obtain additional rights of use, visit http://www.opengeospatial.org/legal/ .
	-->

	<import namespace="http://www.w3.org/1999/xlink" schemaLocation="http://www.w3.org/1999/xlink.xsd"/>

Unfortunately xsd.exe does not resolve the import automatically, so in order to make it work I just copied the xlinx.xsd to my schemas folder and specified it in the command:

xsd schemas\xlink.xsd schemas\capabilities_1_3_0.xsd /c

Looks like this did the trick and the classes got generated as expected. The complete set of files is here: 

ogc_wms_cs_from_xsd.zip (51.1KB)