Calling COM method (CallByName) with reference parameters

Cetan

New member
Joined
Apr 2, 2008
Messages
1
Programming Experience
5-10
I'm converting a DLL-test tool originally build in VB6 to VB.NET
In the old tool the method CallByName is used to invoke a method in the DLL:

VB.NET:
CallByName(objDLL, strFunction, VbMethod, arrParameters)

The arrParameters can be (one or more) IN parameters, OUT parameters or IN/OUT parameters
In the old VB6 tool the arrParameters array is correctly filled with the results from the DLL method but in VB.NET it is not.

I looked it up in the MSDN documentation and noticed that CallByName (in .NET) sends the paremeters ByVal so that explains why it does not work anymore. (I presume in VB6 the parameters where send ByRef )

However, I have a problem now, because I need the parameters to be send ByRef.

I also tried the .NET method InvokeMember but this has the same problem.
I even included the parameter modifier (convinced this was the solution I needed) but no cigar... :confused:

VB.NET:
'Set parameter modifier: handle all parameters as reference

Dim p As New ParameterModifier(parameters.Count)

For i = 0 To parameters.Count - 1
    p(i) = True
Next
Dim mods() As ParameterModifier = {p}

Dim a As Object
'Call the DLL method
a = _currentApi.GetType().InvokeMember(method, BindingFlags.InvokeMethod, Nothing, _currentApi, parameters, mods, Nothing, Nothing)

Does someone know what the problem is in this case and more importantly: how to solve this?!

Thanks a lot for any help... this is a showstopper for me! :(
 
Back
Top