var clr= new core.VW.Clr.Manager() var test= async function(){ // Esta parte se demora un poco mientras se carga por completo el canal de comunicación await clr.loadAssembly("System.Xml") // La primera vez se demora un poco más porque carga los miembros de los tipos var d= new Date() await testxml() console.info("Time: ", new Date()-d) var d= new Date() await testxml() console.info("Time: ", new Date()-d) var d= new Date() await testxmlScope() console.info("Time: ", new Date()-d) var d= new Date() await testxmlScope() console.info("Time: ", new Date()-d) await clr.close() process.exit(0) } var testxml= async function(){ try{ var Xml= {} // Cargar los tipos ... Xml.Document= clr.get("System.Xml.XmlDocument") await Xml.Document.loadMembers() var doc= await Xml.Document.create() var root= await doc.CreateXmlDeclaration("1.0","utf8","yes") await doc.AppendChild(root) var elemento1= await doc.CreateElement("element1") var elemento2= await doc.CreateElement("element2") await elemento1.AppendChild(elemento2) await elemento2.setInnerText("Hola mundo!") await doc.AppendChild(elemento1) console.info(await doc.getOuterXml()) var tasks=[root.dispose(), elemento1.dispose(), elemento2.dispose(), doc.dispose()] await core.VW.Task.waitMany(tasks) } catch(er){ console.error(er) } } var testxmlScope= async function(){ try{ var Xml= {} // Cargar los tipos ... var scope= clr.beginScope() Xml.Document= clr.get("System.Xml.XmlDocument") await Xml.Document.loadMembers() var doc= await scope(Xml.Document).create() var root= await doc.CreateXmlDeclaration("1.0","utf8","yes") await doc.AppendChild(root) var elemento1= await doc.CreateElement("element1") var elemento2= await doc.CreateElement("element2") await elemento1.AppendChild(elemento2) await elemento2.setInnerText("Hola mundo!") await doc.AppendChild(elemento1) console.info(await doc.getOuterXml()) await scope.end() } catch(er){ console.error(er) } } test()