Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello. I have this code
C#
private void TreeViewItem_Selected(object sender, RoutedEventArgs e)
{
     Assembly assembly = Assembly.GetExecutingAssembly();
     string NAME = "WpfApplication2.Res.Pages."+treeView1.Name+".xaml";

    using (Stream stream = assembly.GetManifestResourceStream(NAME))
    {
        FlowDocument document = (FlowDocument)XamlReader.Load(stream);
        flow.Document = document;
    }
}


After compiling I choose item from treeView and get ArgumentNullException for this line
C#
FlowDocument document = (FlowDocument)XamlReader.Load(stream);


How to fix it? Thank you
Posted
Updated 16-Oct-14 4:52am
v2

1 solution

Use as follows,
C#
using (Stream stream = assembly.GetManifestResourceStream(this.GetType(), NAME))
{
   FlowDocument document = (FlowDocument)XamlReader.Load(stream);
   flow.Document = document;
}


Here I just changed
C#
assembly.GetManifestResourceStream(NAME)

to
C#
assembly.GetManifestResourceStream(this.GetType(), NAME)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900