Private mAppPath As String = My.Application.Info.DirectoryPath & "\" & My.Application.Info.Productname & ".exe"
'函数
Private Function FindAssemblyByname(ByVal classname As String,ByVal methodname As String) As Object
Dim objAssembly As Assembly = Assembly.LoadFrom(mAppPath)
Dim types() As Type = objAssembly.GetTypes
Dim objResult As Object = nothing
msbText = New StringBuilder
Dim j As Integer
For Each mtype As Type In types
If mtype.name = classname Then
Dim objMethodInfo As System.Reflection.MethodInfo = mtype.getmethod(methodname)
If objMethodInfo Is nothing Then
MsgBox("関数が存在しません または 権限が私有かもしれません")
Exit For
End If
Dim objAdapter As Object = Activator.CreateInstance(mtype)
Dim Param As ParameterInfo
Dim Params As ParameterInfo() = objMethodInfo.GetParameters()
If Params.Count > 0 Then
msbText.Appendline("--引数リスト---------------")
End If
For Each Param In Params
j = j + 1
msbText.Appendline("--引数[" & CStr(j) & "]--")
msbText.Appendline("Param=" + Param.name.ToString())
msbText.Appendline(" Type=" + Param.ParameterType.ToString())
msbText.Appendline(" position=" + Param.position.ToString())
msbText.Appendline(" Optional=" + Param.IsOptional.ToString())
Next Param
If Not Params Is nothing AndAlso Params.Count > 0 Then
Dim obJs As Object = New Object()
ReDim obJs(Params.Count - 1)
obJs(0) = mDBConn
For i As Integer = 0 To Params.Count - 2
obJs(i + 1) = mAryTextBox.Item(i)
Next
objResult = objMethodInfo.Invoke(objAdapter,obJs)
Else
objResult = objMethodInfo.Invoke(objAdapter,nothing)
End If
Exit For
End If
Next
Return objResult
End Function
总结以上是内存溢出为你收集整理的vb.net2008 指定类名和方法名进行测试用的工具全部内容,希望文章能够帮你解决vb.net2008 指定类名和方法名进行测试用的工具所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)