Impossible d'insérer le fichier "newChild" OpenXmlElement, car il fait partie d'un arbre

Le Titre de membres de l'erreur que j'obtiens. Je suis en train de cacher tout le texte dans un document word à l'aide d'OpenXml. Actuellement, lorsque j'essaie de l'ajouter les propriétés de Paragraphe je reçois l'erreur ci-dessus. Je ne trouve pas beaucoup sur cette erreur en ligne.

Code qui renvoie l'erreur

        using (WordprocessingDocument wdDoc = WordprocessingDocument.Open(mDoc_copy, true))
        {
            //Manage namespaces to perform XPath queries.
            NameTable nt = new NameTable();
            XmlNamespaceManager nsManager = new XmlNamespaceManager(nt);
            nsManager.AddNamespace("w", wordmlNamespace);

            //Get the document part from the package.
            //Load the XML in the document part into an XmlDocument instance.
            XmlDocument xdoc = new XmlDocument(nt);
            xdoc.Load(wdDoc.MainDocumentPart.GetStream());

            MainDocumentPart main = wdDoc.MainDocumentPart;

            IEnumerable<OpenXmlElement> elem = main.Document.Body.Descendants().ToList();
            Paragraph p;
            ParagraphProperties pp = new ParagraphProperties();
            ParagraphMarkRunProperties prmp = new ParagraphMarkRunProperties();
            Vanish v = new Vanish();
            apprmp.AppendChild<Vanish>(v);
            pp.AppendChild<ParagraphMarkRunProperties>(apprmp);


            foreach (Paragraph para in main.Document.Body.Descendants<Paragraph>().ToList())
            {


                    para.ParagraphProperties = pp;

            }
       }

source d'informationauteur user1704863 | 2013-05-01