Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is the proof of concept that I finally came up with for this question. It is not without flaws but I believe that with a little work it will function properly.</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.Design; using System.Reflection; using System.Windows.Forms; namespace ReferencedAssemblies { public partial class GetReferencedComponents : Component, ISupportInitialize { private Control hostingControl; public GetReferencedComponents(IContainer container) : this() { container.Add(this); } public GetReferencedComponents() { InitializeComponent(); Assemblies = new List&lt;string&gt;(); GetAssemblies(); } public List&lt;string&gt; Assemblies { get; private set; } [Browsable(false)] public Control HostingControl { get { if (hostingControl == null &amp;&amp; this.DesignMode) { IDesignerHost designer = this.GetService(typeof(IDesignerHost)) as IDesignerHost; if (designer != null) hostingControl = designer.RootComponent as Control; } return hostingControl; } set { if (!this.DesignMode &amp;&amp; hostingControl != null &amp;&amp; hostingControl != value) throw new InvalidOperationException("Cannot set at runtime."); else hostingControl = value; } } public void BeginInit() { } public void EndInit() { // use ISupportInitialize.EndInit() to trigger loading assemblies at design-time. GetAssemblies(); } private void GetAssemblies() { if (HostingControl != null) { if (this.DesignMode) MessageBox.Show(String.Format("Getting Referenced Assemblies from {0}", HostingControl.Name)); Assemblies.Clear(); AssemblyName[] assemblyNames = HostingControl.GetType().Assembly.GetReferencedAssemblies(); foreach (AssemblyName item in assemblyNames) Assemblies.Add(item.Name); } } } </code></pre> <p>}</p> <p>Thanks for your answers!</p> <p>Mike</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload