dot.net com class function

  • Thread starter Thread starter gs
  • Start date Start date
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.
 
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
 
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.
 
Back
Top