dot.net com class function

G

gs

what is the proper interop description for result of string array for an
function that is to be called through com interface by legacy application?

I tried
Public Function etstor0(<Out()> ByRef iCnt As Integer, _
<Out()> <MarshalAs(UnmanagedType.LPArray,
ArraySubType:=UnmanagedType.LPStr, SizeParamIndex:=0)> ByRef
strMatchReslts() As String _
) As Integer

----
end Function

I was calling something like this from a legacy application

// establish, initialize the com class object: myComclass
string sresult[]
long ll_cnt, ll_rc

ll_rc = myComclass.estor(Ref ll_cnt, Ref sresult)


but I got a message saying
Error calling external object function etstor0


I have established that in this legacy application, long is the vb integer,
and plan old string without array is ok with calling this .net com class
function that do not involve arrays.
 
D

Dragon

Does your function change the array as a whole (I mean, something like
strMatchResults = New String(){...})? If it doesn't, then you maybe have
to declare strMatchResults ByVal, not ByRef.

Roman
 
G

gs

the function does change the array with match results from regex operations
Dragon said:
Does your function change the array as a whole (I mean, something like
strMatchResults = New String(){...})? If it doesn't, then you maybe have
to declare strMatchResults ByVal, not ByRef.

Roman

gs said:
what is the proper interop description for result of string array for an
function that is to be called through com interface by legacy application?

I tried
Public Function etstor0(<Out()> ByRef iCnt As Integer, _
<Out()> <MarshalAs(UnmanagedType.LPArray,
ArraySubType:=UnmanagedType.LPStr, SizeParamIndex:=0)> ByRef
strMatchReslts() As String _
) As Integer

----
end Function

I was calling something like this from a legacy application

// establish, initialize the com class object: myComclass
string sresult[]
long ll_cnt, ll_rc

ll_rc = myComclass.estor(Ref ll_cnt, Ref sresult)


but I got a message saying
Error calling external object function etstor0


I have established that in this legacy application, long is the vb integer,
and plan old string without array is ok with calling this .net com class
function that do not involve arrays.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top