What is causing 'CA2202: Do not dispose objects multiple times' in this code and how can I refactor?

后端 未结 2 433
醉话见心
醉话见心 2020-12-06 19:28

I have the function below which is used to serialize an object without adding the XML declaration. I\'ve just opened the project containing it an Visual Studio 2012 and the

2条回答
  •  感情败类
    2020-12-06 20:15

    Try to modify the code to have 2 separate usings:

    Using stream As New StringWriter()
        Using writer As XmlWriter = XmlWriter.Create(stream, settings)
    
        End Using
    End Using
    

提交回复
热议问题