Home All Groups Group Topic Archive Search About

dot.net com class function

Author
11 May 2006 9:52 PM
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.

Author
12 May 2006 2:20 PM
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

Show quoteHide quote
"gs" <g*@nomail.nil> ñîîáùèë/ñîîáùèëà â íîâîñòÿõ ñëåäóþùåå:
news:#b7fCVUdGHA.4224@TK2MSFTNGP04.phx.gbl...
> 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.
>
>
Author
13 May 2006 4:35 AM
gs
the function does change the array with match results from regex operations
Show quoteHide quote
"Dragon" <no@spam.please> wrote in message
news:%230RqC9cdGHA.3632@TK2MSFTNGP02.phx.gbl...
> 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" <g*@nomail.nil> ñîîáùèë/ñîîáùèëà â íîâîñòÿõ ñëåäóþùåå:
> news:#b7fCVUdGHA.4224@TK2MSFTNGP04.phx.gbl...
>> 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.
>>
>>
>
>