で失敗し、次のコードは、任意のXMLドキュメントに失敗します。XDocument.LoadはLoadOptions.PreserveWhitespaceを使用する場合にのみ起こるモノ - XDocument.Loadはモノラルバージョン2.10.5を使用してLoadOptions.PreserveWhitespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Xml.Linq;
namespace TestXDocument
{
class MainClass
{
public static void Main (string[] args)
{
Stream s = File.Open("Settings.xml", FileMode.Open);
XDocument d = XDocument.Load(s, LoadOptions.PreserveWhitespace);
s.Close();
d.Save("Settings.xml");
}
}
}
。どのようにこれを回避するか、または問題を解決する上で任意のアイデア?
Linux Mint 12およびUbuntu 11.10でテスト済みです。ここで
は例外です:
Unhandled Exception: System.InvalidOperationException: This XmlWriter does not accept Text at this state Prolog.
at System.Xml.XmlTextWriter.ShiftStateContent (System.String occured, Boolean allowAttribute) [0x00000] in <filename unknown>:0
at System.Xml.XmlTextWriter.WriteString (System.String text) [0x00000] in <filename unknown>:0
at System.Xml.DefaultXmlWriter.WriteString (System.String text) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XText.WriteTo (System.Xml.XmlWriter w) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.WriteTo (System.Xml.XmlWriter w) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Save (System.Xml.XmlWriter w) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Save (System.String filename, SaveOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Save (System.String filename) [0x00000] in <filename unknown>:0
at TestXDocument.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: This XmlWriter does not accept Text at this state Prolog.
at System.Xml.XmlTextWriter.ShiftStateContent (System.String occured, Boolean allowAttribute) [0x00000] in <filename unknown>:0
at System.Xml.XmlTextWriter.WriteString (System.String text) [0x00000] in <filename unknown>:0
at System.Xml.DefaultXmlWriter.WriteString (System.String text) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XText.WriteTo (System.Xml.XmlWriter w) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.WriteTo (System.Xml.XmlWriter w) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Save (System.Xml.XmlWriter w) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Save (System.String filename, SaveOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Save (System.String filename) [0x00000] in <filename unknown>:0
at TestXDocument.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0
Monoの問題を公式のbugzilla(http://www.mono-project.com/Bugs)で報告する方法を学ぶ必要があります –
質問がありますか? – sehe
ここでの質問です:どのように私はそれを解決するか、回避することができます。 –