Hi all,
In VB.net,using Type.InvokeMember to call a method of
a class in COM dll,the method has a reference
parameter,It seems that there is no way to return the
changed value of that reference parameter by the method
of the class.
For example,
an COM class named myclass ,it has a method named
mymethod an its VB code is like this:
Public Class myClass
Public Function mymethod(ByVal a As Integer, ByVal b
As Integer, ByRef c As Integer) As Integer
c = a - b
Return a + b
End Function
End Class
The class has been compiled into a COM dll named
myTest.dll,then use it in VB.NET,like this:
Dim Aobj() As Object = {15, 6, 3}
MsgBox(Aobj(2))
Dim obj As New myTest.myclass()
Dim T As Type = Type.GetTypeFromProgID("myTest.myclass")
dim d as object
d= T.InvokeMember("mymethod",
Reflection.BindingFlags.Public Or
Reflection.BindingFlags.InvokeMethod Or
Reflection.BindingFlags.Instance, Nothing, obj, Aobj)
MsgBox(Aobj(2))
MsgBox(d)
IN the code,the desired value of Aobj(2) is 9,but it
remains 3.
what shall I do ? Whther I must use "ParameterModifier"?
and how to use it?
Who can save me?
Thanks a lot!
An early reply will be appreciated.