AppDomain UserControl

Hello,

I was wondering how i could accomplish something like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
private void form_Load(object sender, EventArgs e)
        {

            try
            {
                AppDomain sandbox = AppDomain.CreateDomain("Sandbox");
                Console.WriteLine(typeof(MyUserControl).Assembly.FullName);
                ObjectHandle hobj = sandbox.CreateInstance(typeof(MyUserControl).Assembly.FullName, "MyControl.NewUserControl");
                MyUserControl so = (MyUserControl)hobj.Unwrap();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }

    [Serializable]
    public partial class MyUserControl : System.Windows.Forms.UserControl
    {
        public MyUserControl()
        {
            InitializeComponent();
        }

        ...

    }


There's always a TypeLoadException. Is there anyway I can crate the user control in another appdomain, such as a plugin manager? The goal is to exclude the MyUserControl into a separate DLL an load the one I wish to at runtime.

Cheers
Nico
That is C#. Try the MSDN forums.
Topic archived. No new replies allowed.