Dynamically loaded dll interface function returns usercontrol
<p>For a minor project I have created a basic interface which is used to create plugins. This interface has a function that returns a UserControl. However when this is called and the UserControl is added to a panel nothing shows in the panel (even if <code>.Show()</code> or <code>Visibility = true</code> is set). I had assumed that when the <code>assembly.CreateInstance()</code> is called this creates instances of any objects in the class.</p>

<p>Is this not the case? Is a <code>CreateInstance()</code> required to be called on all UserControls before they can be used in this way? </p>

<pre><code>public interface IMyInterface
{
    System.Windows.Forms.UserControl GetConfigurationControl();
}
</code></pre>

<p>Implemented class in the dll:</p>

<pre><code>public class myClass: IMyInterface
{
    return new myUserControl();
}
</code></pre>

<p>Loaded all dlls in the directory:</p>

<pre><code>private void LoadPlugins()
{
 foreach (string file in Directory.GetFiles(Application.StartupPath+"/plugins/", "*.dll",       SearchOption.AllDirectories))
        {
            Assembly assembly = Assembly.LoadFile(file);
            var types = from t in assembly.GetTypes()
                    where t.IsClass &amp;&amp;
                    (t.GetInterface(typeof(IMyInterface).Name) != null)
                    select t;
            foreach (Type t in types)
            {
                IMyInterface plugin = (IMyInterface)assembly.CreateInstance(t.FullName, true);
                this.pluginsList.Add(plugin); //just a list of the plugins
            }
        }
    this.AddPluginUserControls();
 }    
</code></pre>

<p>Add the user controls to a panel:</p>

<pre><code> private AddPluginUserControls()
 {
     foreach (IMyInterface plugin in pluginsList)
     {
          myPanel.Controls.Add(plugin.GetConfigurationControl());
     }
 }
</code></pre>

<p>I am aware of other full plugin architectures however this is more a learning application.
Thanks!</p>

<p>UserControl:</p>

<pre><code>public partial class myUserControl: UserControl
{
    public myUserControl()
    {
        InitializeComponent(); // couple of labels, vs generated.
    }
}
</code></pre>
