Hi All,
I am displaying the list of all the methods of an assembly in DataList in a Aspx page.when a user selects a method from the list, it's definition should be displayed in a textbox.I am using Reflection to Display the Method names in the list,but I am facing problem to fetch the definition of the method .I have used the folloing code to populate the list:
Please help me in Displaying the Definition of selected Method in textbox.
'Load the assembly and get all the types.
assembly1 = [Assembly].LoadFile(strDllPath & strFile) 'Path of the assembly
types = assembly1.GetTypes
Catch ex As FileNotFoundException
lblResult.Text = "File not found Exception"
Catch ex1 As TypeLoadException
lblResult.Text = "Type load Exception"
Catch ex2 As Exception
lblResult.Text = "other Exception"
End Try
Do While (i < types.Length)
'Fetch the Methods of the type in the assembly.
Dim methods() As MethodInfo = types(i).GetMethods
'Add the Methods of the type in the assembly as child nodes.
If (methods Is Nothing) Then
lstBaseFunctions.Items.Add("No Methods Found")
Else
For Each m As MethodInfo In methods
If m.Name.ToUpper.Equals("VERSION") Or m.Name.ToUpper.Equals("GETTYPE") Or m.Name.ToUpper.Equals("TOSTRING") Or m.Name.ToUpper.Equals("GETHASHCODE") Or m.Name.ToUpper.IndexOf("EQUALS") >= 0 Then
Else
Dim parameters() As ParameterInfo = m.GetParameters
strParam = " ("
For Each param As ParameterInfo In parameters
'Add each of the parameters in the tree.
strParam = strParam & param.Name & "(" & param.ParameterType.ToString & "),"
Next
If strParam.Length > 2 Then
strParam = Mid(strParam, 1, Len(strParam) - 1) & ")"
Else
strParam = ""
End If
intCount += 1
dtRow = dtFuntionName.NewRow
dtRow("FunctionName") = (m.Name & strParam)
dtRow("FunctionId") = intCount
dtFuntionName.Rows.Add(dtRow)
End If