'原始DLL內容
Public Class Class1
Public Sub MSG()
MsgBox(Date.Now.Date.ToString("yyyy/MM/dd"))
End Sub
End Class
'呼叫方法
Imports System
Imports System.Reflection
Imports System.Security.Permissions
Public Class Form1
Dim TAA As System.Reflection.Assembly
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TAA = System.Reflection.Assembly.LoadFile(System.Windows.Forms.Application.StartupPath & "\888.dll")
Dim t As Type = TAA.GetType("_888.Class1") '注意,前面有『_』喔,這是vb.net 2005預先幫你加上去的
Dim obj As Object = t.InvokeMember(Nothing, BindingFlags.DeclaredOnly Or _
BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.Instance Or _
BindingFlags.CreateInstance, Nothing, Nothing, Nothing)
obj.msg()
End Sub
End Class
全站熱搜
留言列表