Disferente
Programmer
How do I use a class library dll that I don't add a reference at design time. I only want to use it if it is selected in the program.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Class Class1
Shared Sub DoSomething()
System.Windows.Forms.MessageBox.Show("hello from SimpleClassLibrary")
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim scl As System.Reflection.Assembly = System.Reflection.Assembly.LoadFile("c:\SimpleClassLibrary.dll")
Dim t As Type = SCL.GetType("SimpleClassLibrary.Class1")
t.InvokeMember("DoSomething", Reflection.BindingFlags.InvokeMethod, Nothing, Nothing, Nothing)
End Sub
Public Class Class1
Shared Sub DoSomething()
System.Windows.Forms.MessageBox.Show("hello from SimpleClassLibrary")
End Sub
[b]
Sub DoSomethingElse()
System.Windows.Forms.MessageBox.Show("hello from SimpleClassLibrary -- instance")
End Sub[/b]
End Class
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim scl As System.Reflection.Assembly = System.Reflection.Assembly.LoadFile("c:\SimpleClassLibrary.dll")
Dim t As Type = SCL.GetType("SimpleClassLibrary.Class1")
t.InvokeMember("DoSomething", Reflection.BindingFlags.InvokeMethod, Nothing, Nothing, Nothing)
End Sub
[b]
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim scl As System.Reflection.Assembly = System.Reflection.Assembly.LoadFile("c:\SimpleClassLibrary.dll")
Dim t As Type = scl.GetType("SimpleClassLibrary.Class1")
Dim first_instance As Object = scl.CreateInstance("SimpleClassLibrary.Class1")
t.InvokeMember("DoSomethingElse", Reflection.BindingFlags.InvokeMethod, Nothing, first_instance, Nothing, Nothing)
End Sub[/b]
End Class