[Mono-bugs] [Bug 336927] New: [LinqToXml] System.InvalidOperationException : XmlWriter does not accept Text at this state Start.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Oct 25 17:36:52 EDT 2007


https://bugzilla.novell.com/show_bug.cgi?id=336927

           Summary: [LinqToXml] System.InvalidOperationException : XmlWriter
                    does not accept Text at this state Start.
           Product: Mono: Class Libraries
           Version: unspecified
          Platform: x86-64
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.XML
        AssignedTo: atsushi at ximian.com
        ReportedBy: peyroux at gmail.com
         QAContact: mono-bugs at ximian.com
          Found By: ---


When i test simple LinqToXml exemple with olive module, i have an error.

---- 8< --- code --- 8< ----
using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections.Generic;

class Linquou
{
   public static void Main(string[] args)
   {
       XElement root = XElement.Load(@"utilisateur.xml");
       if(root.Element("utilisateurs") != null) {
           var listUser = from u in
                          root.Element("utilisateurs").Elements("utilisateur")
                          select
                          new { Nom = u.Element("nom").Value,
                                                        Prenom =
u.Element("prenom").Value
                                                       };

           foreach(var u in listUser) {
               System.Console.WriteLine("An user: {0} {1}", u.Prenom, u.Nom);
           }
       }
   }
}
---- 8< --- end code --- 8< ----

I compile this code with :

gmcs -r:System.Core.dll -r:lib/System.Xml.Linq -langversion:linq sampleLinq.cs

Compilation return 0 error but when i run sampleLinq.exe i have this
error :

[mono] ~/Codaz/Cs/linqt @ make
gmcs -r:System.Core.dll -langversion:linq  -r:lib/System.Xml.Linq
exemple2.cs -out:exemple2.exe
[mono] ~/Codaz/Cs/linqt @ mono exemple2.exe

Unhandled Exception: System.InvalidOperationException: This XmlWriter
does not accept Text at this state Start.
at System.Xml.XmlTextWriter.ShiftStateContent (System.String occured,
Boolean allowAttribute) [0x00000]
at System.Xml.XmlTextWriter.WriteString (System.String text)
[0x00000]
at System.Xml.Linq.XText.WriteTo (System.Xml.XmlWriter w)
[0x00000]
at System.Xml.Linq.XNode.ToString (SaveOptions options)
[0x00000]
at System.Xml.Linq.XNode.ToString () [0x00000]
at System.Text.StringBuilder.Append (System.Object value)
[0x00000]
at System.Xml.Linq.XElement.get_Value () [0x00000]
at
Linquou+<>c__CompilerGenerated0.<Main>c__1[XElement,<>__AnonType0`2]
(System.Xml.Linq.XElement u) [0x00000]
at
System.Linq.Enumerable+<>c__CompilerGenerated13`2[System.Xml.Linq.XElement,<>__AnonType0`2[System.String,System.String]].MoveNext
() [0x00000]
at Linquou.Main (System.String[] args) [0x00000]

xml file for my exemple is :

<?xml version="1.0" encoding="utf-8"?>
<carnet>
<utilisateurs>
       <utilisateur>
               <nom>Peyroux</nom>
               <prenom>Jean Alexandre</prenom>
       </utilisateur>
       <utilisateur>
               <nom>Pommereau</nom>
               <prenom>Eric</prenom>
       </utilisateur>
               <utilisateur>
               <nom>James</nom>
               <prenom>Sylvain</prenom>
       </utilisateur>
</utilisateurs>
</carnet>

Finaly my mono version is :
[mono] ~/Codaz/Cs/linqt @ mono --version
Mono JIT compiler version 1.2.5 (/trunk/ r87936)


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list