sample.vb
class sam
public shared sub hh()
Console.WriteLine("asasas")
end sub
end class
test.vb
Dim ass as Assembly = Assembly.LoadFile("sample.dll")
现在,我想使用类名调用共享方法。我该怎么做?
sample.vb
class sam
public shared sub hh()
Console.WriteLine("asasas")
end sub
end class
test.vb
Dim ass as Assembly = Assembly.LoadFile("sample.dll")
现在,我想使用类名调用共享方法。我该怎么做?
反射是你的朋友。添加一个Imports System.Reflection
并尝试以下操作:
Sub Main()
Dim ass As Assembly = Assembly.LoadFile("sample.dll")
Dim t_sam As Type = ass.GetType("sam")
Dim hh_m As MethodInfo = t_sam.GetMethod("hh", BindingFlags.Public Or BindingFlags.Static)
hh_m.Invoke(Nothing, New Object() {})
End Sub