out keyword (function prototype)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • [GHO}

    #1

    out keyword (function prototype)

    I trying to send an array to my C# dll function which the
    prototype as "C# COM (Dll)":

    public int PrintIO(out System.Int64 [] FreeIO ,out int len)

    But when trying to call this function (CPP file)

    __int64 *heelp;
    int len=0;
    if (cpi->PrintIO(&heelp ,&len) == 0)


    i get the following error:

    "
    COMClient.cpp(6 0): error
    C2664: 'IManagedInterf ace::PrintIO' : cannot convert
    parameter 1 from '__int64 ** ' to 'SAFEARRAY ** '
    "


  • Mattias Sjögren

    #2
    Re: out keyword (function prototype)

    [color=blue]
    >i get the following error:
    >
    >"
    >COMClient.cpp( 60): error
    >C2664: 'IManagedInterf ace::PrintIO' : cannot convert
    >parameter 1 from '__int64 ** ' to 'SAFEARRAY ** '
    >"[/color]

    This is more of a C++ question, but basicly you have to create a
    SAFEARRAY and pass in that instead.



    Mattias

    --
    Mattias Sjögren [MVP] mattias @ mvps.org

    Please reply only to the newsgroup.

    Comment

    • Jim

      #3
      out keyword (function prototype)

      Well, I'm a little new to the C# way of doing things
      myself, as you'll see from some of my posts in this forum,
      so I'm by no means the authority on the subject but...

      It seems to me that your C# fxn wants an array of
      pointers, and you're making it an OUT argument, presumably
      becasue it will modify the contents of the original array
      (otherwise you woldn't pass ti as an out, which is, as I
      understand it, effectively passing it by reference instead
      of by value). However, you are only passing in the
      address of a pinter to an __int64, not a pointer to an
      array. Me thinks you might want to change your variable
      declaration in the C++ file to

      __int64* heelp[20]; // or however many you need.

      If you don't know how many you need, then you'll have to
      create a (**) (piotner to a pointer... Man I love C++ :-
      ) )... and then initialize it with something...

      __int64 **help; // Pointer to a pointer of __int64
      *heelp = new __int64[25];
      ....
      delete *heelp[];

      But that might put you right back in the same boat. There
      is another fxn in C++ I used to use when donig stuff with
      ADO and dynamic arrays, a fxn called "CreateSaffeArr ay()",
      and you might want to take a look at that as well.

      Again, I'm not the authoority on C#, nor anything else...
      Hehehe.. But I hope that helps you out. If not, let me
      know and we can take another stab at it. :)

      JIM

      [color=blue]
      >-----Original Message-----
      >I trying to send an array to my C# dll function which the
      >prototype as "C# COM (Dll)":
      >
      >public int PrintIO(out System.Int64 [] FreeIO ,out int[/color]
      len)[color=blue]
      >
      >But when trying to call this function (CPP file)
      >
      > __int64 *heelp;
      > int len=0;
      > if (cpi->PrintIO(&heelp ,&len) == 0)
      >
      >
      >i get the following error:
      >
      >"
      >COMClient.cpp( 60): error
      >C2664: 'IManagedInterf ace::PrintIO' : cannot convert
      >parameter 1 from '__int64 ** ' to 'SAFEARRAY ** '
      >"
      >
      >
      >.
      >[/color]

      Comment

      • [Gho]

        #4
        Re: out keyword (function prototype)

        "create a SAFEARRAY and pass in that instead."
        How to do that?


        [color=blue]
        >-----Original Message-----
        >[color=green]
        >>i get the following error:
        >>
        >>"
        >>COMClient.cpp (60): error
        >>C2664: 'IManagedInterf ace::PrintIO' : cannot convert
        >>parameter 1 from '__int64 ** ' to 'SAFEARRAY ** '
        >>"[/color]
        >
        >This is more of a C++ question, but basicly you have to [/color]
        create a[color=blue]
        >SAFEARRAY and pass in that instead.
        >
        >
        >
        >Mattias
        >
        >--
        >Mattias Sjögren [MVP] mattias @ mvps.org
        >http://www.msjogren.net/dotnet/
        >Please reply only to the newsgroup.
        >.
        >[/color]

        Comment

        • Mattias Sjögren

          #5
          Re: out keyword (function prototype)

          [color=blue]
          >"create a SAFEARRAY and pass in that instead."
          >How to do that?[/color]

          Use the SafeArrayCreate Ex API or some wrapper class. I'm sure you can
          get more help in this in the C++ newsgroup.



          Mattias

          --
          Mattias Sjögren [MVP] mattias @ mvps.org

          Please reply only to the newsgroup.

          Comment

          • Austin Ehlers

            #6
            Re: out keyword (function prototype)

            Look up SafeArray in the help.

            //should work
            public int PrintIO(([MarshalAs(Unman agedType.SafeAr ray,
            SafeArraySubTyp e=VT_I8)]System.Int64 [] FreeIO ,out int len);





            On Tue, 18 Nov 2003 07:15:21 -0800, "[GHO}" <yousefk@taux01 .nsc.com>
            wrote:
            [color=blue]
            >I trying to send an array to my C# dll function which the
            >prototype as "C# COM (Dll)":
            >
            >public int PrintIO(out System.Int64 [] FreeIO ,out int len)
            >
            >But when trying to call this function (CPP file)
            >
            > __int64 *heelp;
            > int len=0;
            > if (cpi->PrintIO(&heelp ,&len) == 0)
            >
            >
            >i get the following error:
            >
            >"
            >COMClient.cpp( 60): error
            >C2664: 'IManagedInterf ace::PrintIO' : cannot convert
            >parameter 1 from '__int64 ** ' to 'SAFEARRAY ** '
            >"
            >[/color]

            Comment

            Working...