I would like to put settings to my XmlWriter. I've an issue when I serialize my object with XmlWriter. My object is simple object with get/set.
When I call the serialize function I've this error :
Error generating XML document
Full StackTrace :
Inner Exception : 
System.InvalidOperationException {"WriteStartDocument can not be called 
on writers created with ConformanceLevel.Fragment."} System.InvalidOperationException
Erreur lors de la génération du document XML.
----------------------------------------------------  
 à System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
 à System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces)
 à ...\Classes\MyClasse.vb:ligne 350
Public Function ObjectToXML() As String
    Try
        Dim xmlSerializer As New XmlSerializer(Me.GetType, AttrOverrides)
        Dim ns As New XmlSerializerNamespaces()
        ns.Add("", "")
        Dim settings As New XmlWriterSettings()
        settings.ConformanceLevel = ConformanceLevel.Fragment
        settings.OmitXmlDeclaration = True
        Dim writer As XmlWriter = XmlWriter.Create(New MemoryStream(), settings)
        xmlSerializer.Serialize(writer, Me, ns)
        writer.Close()
        Return writer.ToString
    Catch ex As Exception
        Error()
    End Try
End Function
My serialization work when I remove settings from my XmlWriter.
How to use settings with XmlWriter ?
