Hi all,I have written an application that makes use of the DisplayLayouts' SaveAsXml() and LoadFromXml() functions.Everything works fine until I bind a DataTable (manually constructed) that has column names containing special characters like äöü etc.The LoadFromXml() call fails giving a System.Xml.XmlException: "Invalid character in the given encoding. Line xyz, position xyz."
Is there a way to deal with such column names or anything I can do to make the function work with such DisplayLayouts?Renaming the columns unfortunately isn't an option.
thanks in advance and have a great dayAndy
Hi Mike,
I hope you are doing good.
Thanks a lot for this suggestion... it totally makes sense.I'll stick to this approach :)
cheers and thanks for this suggestionAndy
Hi,
Using an Encoder to convert the stream into a string is a really bad idea. The whole point of an Encoder is to manipulate the stream and coerce it into a string of a particular encoding type. Modifying the stream in this way is basically just asking for it to be damaged.
If you want to convert the stream into a string, a better way to do it would be to use the StreamReader class - and then use a StreamWriter to get it back into a stream.
There's a similar discussion thread where I posted some sample code here:
Convert String to Stream correctly for DisplayLayout.Load() - Infragistics Community
Hello,
Thank you for your feedback, please let me know if you have any question or if something comes up.
Hi Boris,after carefully investigating the video there was one thing that made me look closer.Actually everything you did was exactly what I did, but while comparing the outputs I found a slight difference. I had a decoder fallback operation in my output, you didn't.
So I changedEncoding.Default.GetBytes(displayLayoutAsString)
toEncoding.UTF32.GetBytes(displayLayoutAsString)
That seems to do the trick...
I will check with my main application but I am optimistic that this will fix the problem.
I am deeply sorry for troubling you with this problem, but I appreciated you help very much.That again was a perfect sample for great support! Keep it up :)
So thank you very much Boris and have a great weekend,best regardsAndy
Hello Andy,
I indeed will research this further and for now am attaching a video from the execution of this sample(without changing any assemblies or something else).
Please take a look, I might be missing something, hope you could guide me if I am.