How to list down all properties in an assembly (including referenced Assemblies) in a tree like structure?
<p>I want to create a tree view which list down all properties in an assembly. I am able to generate the root nodes using the following code:</p>

<pre><code>mainAssembly = Assembly.LoadFile(filename); //Global Variable
Type[] objTypes = mainAssembly.GetTypes().OrderBy(o=&gt;o.Name).ToArray();
foreach (var type in objTypes)
{
    TreeViewItem item = new TreeViewItem();
    item.Header = type.Name;
    item.Foreground = Brushes.White;
    item.ToolTip = type.FullName;
    tvEntities.Items.Add(item);
}
</code></pre>

<p>On click of the root node [class name], I want to list down properties contained in that particular class. But if it contains an aggregated property of type <strong>class1</strong>, which is in another assembly, it gives me <strong>IOFileNotFound</strong> Exception error.</p>

<pre><code>private void ItemExpanded(object sender, RoutedEventArgs e)
{
    try
    {
        TreeViewItem item = e.OriginalSource as TreeViewItem;

        if (item.ToolTip != null)
        {
            Type assemblyType = mainAssembly.GetType(item.ToolTip.ToString());
            if (assemblyType != null)
            {

                foreach (var prop in assemblyType.GetProperties())
                {

                    PropertyInfo property = prop;
                    TreeViewItem childItem = new TreeViewItem();
                    childItem.Header = property.Name;
                    /*Following line gives IOFileNotFound exception, if property  is declared in some other assembly.*/
                    childItem.ToolTip = property.PropertyType.FullName;
                    item.Items.Add(childItem);
                }
            }
       }
   }
   catch (Exception ex)
    {
        throw ex;
    }
}                           
</code></pre>

<p>How to load these referenced assemblies and show a tree like structure.</p>
