[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


           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
                          new { Nom = u.Element("nom").Value,
                                                        Prenom =

           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)
at System.Xml.Linq.XText.WriteTo (System.Xml.XmlWriter w)
at System.Xml.Linq.XNode.ToString (SaveOptions options)
at System.Xml.Linq.XNode.ToString () [0x00000]
at System.Text.StringBuilder.Append (System.Object value)
at System.Xml.Linq.XElement.get_Value () [0x00000]
(System.Xml.Linq.XElement u) [0x00000]
() [0x00000]
at Linquou.Main (System.String[] args) [0x00000]

xml file for my exemple is :

<?xml version="1.0" encoding="utf-8"?>
               <prenom>Jean Alexandre</prenom>

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