NullReferenceException when reading a schema xml fix

In some cases reading a valid schema xml (which worked in MS.Net) would cause null reference exceptions. Here is a simple program that reproduces the problem: https://gist.github.com/pingec/336f087d4e820c4f72cc