Displaying a form from a dynamically loaded DLL

后端 未结 4 650
情深已故
情深已故 2020-12-29 11:14

This is an extension of a question I previously asked here.

Long story short, I dynamically load a DLL and make a type out of it with the following code:

4条回答
  •  情深已故
    2020-12-29 11:41

    Yes, you aren't actually specifying any code to run outside the class initializer. For instance, with forms you have to actually show them.

    You could modify your code to the following...

    Assembly assembly = Assembly.LoadFile("C:\\test.dll");
    Type type = assembly.GetType("test.dllTest");
    Form form = Activator.CreateInstance(type) as Form;
    form.ShowDialog();
    

提交回复
热议问题