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