Set ConformanceLevel to Auto but it is already set to Auto!?

Quick post. I'm currently uplifting an old .NET 1.1 app to 4.5 and when trying to run it was getting the following exception.

System.InvalidOperationException was unhandled by user code
  Message=Token Text in state Start would result in an invalid XML document. Make sure that the ConformanceLevel setting is set to ConformanceLevel.Fragment or ConformanceLevel.Auto if you want to write an XML fragment. 
       at System.Xml.XmlWellFormedWriter.AdvanceState(Token token)
       at System.Xml.XmlWellFormedWriter.WriteString(String text)
       at System.Xml.Xsl.Runtime.XmlQueryOutput.WriteString(String text, Boolean disableOutputEscaping)

Upon checking my code I verified that my XslCompiledTransform had the ConformanceLevel set to Auto. However I was still getting this error.

My online searches then suggested it had something to do with the XmlWriter. However there was no clear way to find the ConformanceLevel of the XmlWriter. After a bit of digging I discovered that when calling XmlWriter.Create one can pass in an XmlWriterSettings object with a ConformanceLevel property. I added this property and passed the object to the XmlWriter in Create. This solved the issue that I encountered.

The lesson from this is not only did the XslCompiltedTransform.OutputSettings ConformanceLevel had to be set to Auto but so did the XmlWriter.

XmlWriterSettings xmlWriterSettings = new XmlWriterSettings{ConformanceLevel = ConformanceLevel.Fragment};
XmlWriter resultWriter = XmlWriter.Create(memoryStream, xmlWriterSettings);
xslt.Transform(elementToTranform, resultWriter);

Nowhere was the specific change detailed so I think this might be useful for others. Please leave a comment if you find this useful.