Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / February 2008

Tip: Looking for answers? Try searching our database.

Invalid high surrogate character (0xDEB6).

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Thielen - 07 Feb 2008 01:25 GMT
I am building an XML document using the standard calls to create elements and
attributes. Occasionally I get the following when calling xmlDoc.OuterXml.
What's going on and how do I avoid this?

System.ArgumentException occurred
 Message="Invalid high surrogate character (0xDEB6). A high surrogate
character must have a value from range (0xD800 - 0xDBFF)."
 Source="System.Xml"
 StackTrace:
      at System.Xml.XmlTextEncoder.Write(String text)
      at System.Xml.XmlTextWriter.WriteString(String text)
      at System.Xml.XmlText.WriteTo(XmlWriter w)
      at System.Xml.XmlAttribute.WriteContentTo(XmlWriter w)
      at System.Xml.XmlAttribute.WriteTo(XmlWriter w)
      at System.Xml.XmlElement.WriteTo(XmlWriter w)
      at System.Xml.XmlElement.WriteContentTo(XmlWriter w)
      at System.Xml.XmlElement.WriteTo(XmlWriter w)
      at System.Xml.XmlElement.WriteContentTo(XmlWriter w)
      at System.Xml.XmlElement.WriteTo(XmlWriter w)
      at System.Xml.XmlElement.WriteContentTo(XmlWriter w)
      at System.Xml.XmlElement.WriteTo(XmlWriter w)
      at System.Xml.XmlElement.WriteContentTo(XmlWriter w)
      at System.Xml.XmlElement.WriteTo(XmlWriter w)
      at System.Xml.XmlElement.WriteContentTo(XmlWriter w)
      at System.Xml.XmlElement.WriteTo(XmlWriter w)
      at System.Xml.XmlElement.WriteContentTo(XmlWriter w)
      at System.Xml.XmlElement.WriteTo(XmlWriter w)
      at System.Xml.XmlDocument.WriteContentTo(XmlWriter xw)
      at System.Xml.XmlDocument.WriteTo(XmlWriter w)
      at System.Xml.XmlNode.get_OuterXml()
      at net.windward.autotag.DocumentDataBuffer.SaveProfileToDoc(DocGlobal
docData, String docFileName) in
C:\src\kahuna\AutoTag\AutoTagCore\net\windward\autotag\DocumentDataBuffer.cs:line 116

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Steven Cheng[MSFT] - 07 Feb 2008 04:54 GMT
Hi Dave,

As for the "Invalid high surrogate character" error you encountered, it is
due to some Unicode specific validation in .NET XML API. Within the .Net
framework, there are lot of string validations for Unicode, not only for
XML. So, this is the correct behaviour.The problem is that the data in the
XML you generated may contains some certain value that is valid in string
or XML, but not valid for UNICODE(utf-16 which has rules for surrogate).

From some former issue, I found that you may encounter this error when
you've encrypted some of the data in the xml which may cause the generated  
value be invalid according to unicode surrogate pair rules.  Is there any
particular data included in your XML document? You can try simplify the XML
document so as to locate the certain data fragment.

BTW, here is a blog article I've found which also mentioned this:

http://blogs.msdn.com/michkap/archive/2006/12/05/1212917.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================
   

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= <thielen@nospam.nospam>
>Subject: Invalid high surrogate character (0xDEB6).
>Date: Wed, 6 Feb 2008 17:25:01 -0800

>I am building an XML document using the standard calls to create elements and
>attributes. Occasionally I get the following when calling xmlDoc.OuterXml.
[quoted text clipped - 27 lines]
>       at System.Xml.XmlNode.get_OuterXml()
>       at
net.windward.autotag.DocumentDataBuffer.SaveProfileToDoc(DocGlobal
>docData, String docFileName) in
>C:\src\kahuna\AutoTag\AutoTagCore\net\windward\autotag\DocumentDataBuffer.cs:line 116
David Thielen - 07 Feb 2008 05:05 GMT
My problem is I don't control the text that goes in many of the nodes &
attributes. Should I be encoding the text somehow? I assumed using the
XmlDocument methods that it would handle any necessary encoding.

Also, all of the text added in this case is ASCII.

Signature

thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

> Hi Dave,
>
[quoted text clipped - 88 lines]
> >C:\src\kahuna\AutoTag\AutoTagCore\net\windward\autotag\DocumentDataBuffer.c
> s:line 116
Steven Cheng[MSFT] - 08 Feb 2008 05:11 GMT
Thanks for your reply Dave,

I think it would be better to identify those nodes that may contains the
pontential problemtic data. Sure, you can perform an additional encoding on
the data so as to ensure it is proper unicode text range.

As you mentioned that all the data is of ASCII char, how were those ASCII
chars generated and embeded into the XML document?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
   

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

>From: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= <thielen@nospam.nospam>
>References:  <BEFB912D-04CF-4210-BEA8-5CBA8964E270@microsoft.com>
<JT7PTWUaIHA.1500@TK2MSFTNGHUB02.phx.gbl>
>Subject: RE: Invalid high surrogate character (0xDEB6).
>Date: Wed, 6 Feb 2008 21:05:01 -0800

>My problem is I don't control the text that goes in many of the nodes &
>attributes. Should I be encoding the text somehow? I assumed using the
[quoted text clipped - 32 lines]
>>
>> Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>> ications.
>>
[quoted text clipped - 58 lines]
>C:\src\kahuna\AutoTag\AutoTagCore\net\windward\autotag\DocumentDataBuffer.c
>> s:line 116

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.