Re: Problem calling a .COM component in :NET with C#

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Murat KARATUTLU (muratk_at_uekae.tubitak.gov.tr)
Date: 07/20/04


Date: Tue, 20 Jul 2004 14:00:48 +0300

The problem might not be Array type but the argument type.
as you see the API function accepts a reference (byref in VB, ref in C#) to
the array of integers, the the array itself.
So you may declare a variable to reference the array and send it to the
function as an [in] arg.

e.g.

to call a function like:
void SomeFunction(ref int x, int y) {
  //implementation goes here
}

you should:
int _x = 10;
int _y = 20;

SomeFunction(ref _x, _y);

but you can NOT
SomeFunction(10, 20);

PS: Also casting may be required for the array type

"Alfonso" <alfonso.navarro@epfl.ch> wrote in message
news:883ba3fb.0407200219.14c82e11@posting.google.com...
> Hello,
>
>
> I am implementing a hanwritting recognition benchmark, and when
> calling from
> my C# code the API of a HWr engine I have the following
>
> Code:
>
> int[] strokes = {myInt1, myInt2, myInt3, myInt4};
> ink.AddStroke(strokes);
>
> problem:
>
> Argument '1': cannot convert from 'int[]' to 'ref System.Array'
>
> Description of API:
>
> 4.2.2.1 AddStroke, AddStrokeXY
> Index = object .AddStroke(Ink ) Index = object .AddStrokeXY(InkX, InkY
> )
> Description
> Adds a stroke to the object.
> Returns assigned zero-based index of the added stroke in the stroke
> array.
> o object is an object expression that evaluates to a riteFormInk
> object.
> o Ink is an array of Longs (in Visual Basic) or Integers (in VB.NET),
> representing
> strokes (X-value in the lower word and Y-value in the upper word).
> o InkX is an array of Integers (in Visual Basic) or Shorts (in
> VB.NET), represented X-values
> of points.
> o InkY is an array of Integers (in Visual Basic) or Shorts (in
> VB.NET), represented Y-values
> of points.
> o Index is a variable of the type Long (in Visual Basic) or Integer
> (in VB.NET) or
> Variant.
> Comment
> Those methods cannot be used in scripting languages that doesn't
> support typed variables
> (like VBScript and JScript).
>
>
>
> I have another code implementet VB .NET which calls the same function
> with an array of Ints and works well.
>
> Any hint?
>
> thanks
>
>
> Alfonso



Relevant Pages

  • Re: Array size discrepancy
    ... gcc version 4.4.3 ... the array object and is not an lvalue. ... type implicitly converted from 6-element array of int to ... array type derivation, then for each call to the function, the value ...
    (comp.lang.c)
  • Re: Surprise in array concatenation
    ... > I didn't say general array indexing is not useful; ... > strings), for example, Ada forces one to change from native array ... popular with scripting languages and a few other new languages. ... up the name of an array type in a C or C++ symbol table. ...
    (comp.lang.ada)
  • Re: Are they equivalent ?
    ... >> Where v is a pointer to an array of characters,defined as ... pointer to char".] ... and if 'v' is truly an array type (as ...
    (comp.lang.c)
  • Re: basic questions on using Ada arrays
    ... But I wanted to make each entry in the array to have some value ... above small loop does, to initialize x array. ... Certainly, but one must use a named array type, not anonymous types as you have done. ... Type String is simply an array type. ...
    (comp.lang.ada)
  • Re: Allocation of memory for Array of Pointers
    ... int main ... You have declared a as a 2-element array of pointers to int; ... you don't need to allocate any memory for a itself. ... You're getting the error because a is an array type, ...
    (comp.lang.c)