4Dont know if this is useful to anyone, but here is a quick app I whipped up exampling the use of Reflection to list all the classes/methods/events/properties of a dll
put this code in a file called dllreport.vb
compile this using 'vbc dllreport.vb'
the run it passing the full path name to any .NET written dll
dllreport c:\mydll.dll
and watch it work. You may find this very helpful considering the power Reflection gives you
Code:' This program writes a report about assembly Imports System Imports System.Reflection Public Module DLLReport Public Sub Main(ByVal args() As String) LoadDLL(args(0)) End Sub Public Sub LoadDLL(ByVal filename As String) Dim asm As [Assembly] ' Assembly is reserved vb word so use the brackets to override Dim myClasses() As Type Dim myMethods() As MethodInfo Dim myEvents() As EventInfo Dim myProperties() As PropertyInfo Dim myTypes As Type Dim myMethodInfo As MethodInfo Dim myEventInfo As EventInfo Dim myPropertyInfo As PropertyInfo asm = [Assembly].LoadFrom(filename) If Not(asm Is Nothing) Then myClasses = asm.GetTypes() End If For Each myTypes In myClasses ' Output Classname Console.Writeline(myTypes.ToString()) ' Lets get all methods(sub and function) from this class myMethods = myTypes.GetMethods() For Each myMethodInfo In myMethods Console.Writeline("---Method---" & myMethodInfo.Name) Next myMethodInfo ' Lets get all events myEvents = myTypes.GetEvents() For Each myEventInfo In myEvents Console.Writeline("---Event---" & myEventInfo.Name) Next myEventInfo ' Lets get all properties myProperties = myTypes.GetProperties() For Each myPropertyInfo In myProperties Console.Writeline("---Properties---" & myPropertyInfo.Name) Next myPropertyInfo Next myTypes End Sub End Module




Reply With Quote