0
I was creating a file and it worked normal, but now, when serialize appears Q1 in all tags, I’m doing this way:
StringWriter sw = new StringWriter();
        XmlTextWriter tw = new XmlTextWriter(sw);
        XmlSerializerNamespaces xsn = new XmlSerializerNamespaces();
        XmlSerializer ser = new XmlSerializer(typeof(GerarNfseEnvio));
        FileStream arquivo = new FileStream("E:\\NFSe-" + "RPS" + numero.ToString().PadLeft(15, '0') + ".xml", FileMode.CreateNew);
        if (item.CodigoMunicipio == 3107109)
        {
            xsn.Add("", "http://www.betha.com.br/e-nota-contribuinte-ws");
        }
        else
        {
            xsn.Add("", "http://www.abrasf.org.br/nfse.xsd");
        }
        ser.Serialize(arquivo, gerar, xsn);
        arquivo.Close();
It worked perfectly, but now the tags appear like this:
<q1:GerarNfseEnvio xmlns="http://www.betha.com.br/e-nota-contribuinte-ws" xmlns:q1="http://www.abrasf.org.br/nfse.xsd">
He’s adding the two, only when I leave only the line  xsn.Add("", "http://www.abrasf.org.br/nfse.xsd"); that works. It was working perfectly. After adding the if, it stayed this way. How to fix?
Doesn’t solve it, keeps popping up the same way
<q1:GerarNfseEnvio xmlns="http://www.betha.com.br/e-nota-contribuinte-ws" xmlns:q1="http://www.abrasf.org.br/nfse.xsd">as if I didn’t have theif– Mariana
Ok, I couldn’t comment before because I don’t have enough points. What you can try is to use the default namespace as second constructor parameter and add the
betha.com.br....with thexsn.Addin the if– gcpdev