Selasa, 04 Februari 2014

Once you know the name of the DLL and the name of the form you want to show, the rest is quite simple. You create an instance of the form, using the Assembly.CreateInstance method, and then call the Show method on the form. The following code snippet is a simplified version of the code in the Dynamic­App Dashboard.Button_Click_Handler method. It demonstrates how to load a DLL called MyDll.dll, create an instance of a form within the DLL Form1, and show the form.
Dim asm As Reflection.Assembly
Dim f As Form
asm = asm.LoadFrom("MyDll.dll")
f = CType(asm.CreateInstance("MyDll.Form1"), Form)
f.Show()
Notice with the CreateInstance method that we have to refer to the form as MyDll.Form1, using the <namespace>.<formname> format. Also be aware that when you write code that loads a DLL dynamically, all names, including the filename and type name, are case sensitive.

Related Posts by Categories

0 komentar:

Posting Komentar