NRE when loading FlowDocument
See original GitHub issueFollowing code throws a NRE in dotnet 7 When loading xaml that has beein previously saved, you will get a NRE . It has something to do with the Run.TextDecoration.
We ran into this issue because of a help tool we created that fails to load help pages since we upgraded to dot net 7.
[TestMethod]
public void ErrorOnXamlSerializeDeserialize()
{
string xaml = "<Section xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" >" +
"<Paragraph><Run>" +
"<Run.TextDecorations><TextDecorationCollection xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"><TextDecoration PenThicknessUnit=\"FontRecommended\" Location=\"Underline\"><TextDecoration.Pen><Pen Brush=\"#FF00FFFF\" Thickness=\"2\" /></TextDecoration.Pen></TextDecoration></TextDecorationCollection></Run.TextDecorations>" +
"xxx</Run></Paragraph></Section>";
MemoryStream mems = new MemoryStream();
mems.Write(Encoding.UTF8.GetBytes(xaml));
mems.Position = 0;
FlowDocument doc = new FlowDocument();
TextRange all = new TextRange(doc.ContentStart, doc.ContentEnd);
all.Load(mems, DataFormats.Xaml);
MemoryStream saveStream = new MemoryStream();
all = new TextRange(doc.ContentStart, doc.ContentEnd);
all.Save(saveStream, DataFormats.XamlPackage);
saveStream.Position = 0;
all = new TextRange(doc.ContentStart, doc.ContentEnd);
all.Load(saveStream, DataFormats.XamlPackage);
}
Issue Analytics
- State:
- Created 9 months ago
- Reactions:1
- Comments:14 (6 by maintainers)
Top Results From Across the Web
Forcing a FlowDocument to Load?
I'm in the process of trying to print out a FlowDocument that is being viewed by the user. I wrote a routine to...
Read more >Flow Document Overview - WPF .NET Framework
A flow document is designed to "reflow content" depending on window size, device resolution, and other environment variables.
Read more >How do I load a FlowDocument XAML content from outside ...
This FAQ explains the topic "How do I load a FlowDocument XAML content from outside the application directory?"
Read more >FlowDocument Class (System.Windows.Documents)
Gets a value indicating whether this element has been initialized, either by being loaded as Extensible Application Markup Language (XAML), or by explicitly ......
Read more >Creating a FlowDocument from Code-behind
So far, we've been creating our FlowDocument's directly in XAML. ... FlowDocument doc = new FlowDocument(); Paragraph p = new Paragraph(new Run("Hello, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@IAmTheCShark See https://devblogs.microsoft.com/dotnet/dotnet-framework-december-2022-security-and-quality-rollup-updates/ and https://support.microsoft.com/kb/5022083
But I do not think the https://support.microsoft.com/kb/5022083 is related
Now some of our customers starting to report this issue on .net 4.8 versions So my guess is this might be some recent change that is distributed via windows update. @lindexi fyi