Pass an array from C++ to C#?

This is a discussion on Pass an array from C++ to C#? within the C++ Programming forums, part of the General Programming Boards category; Hello, I am making my first attempt at some interop between a C++ program which uses a C# DLL. I've ...

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    12

    Pass an array from C++ to C#?

    Hello,

    I am making my first attempt at some interop between a C++ program which uses a C# DLL.

    I've got the C++ interacting with the C# through an interface. Now, I need to pass-by-reference three arrays (int, double, string) from C++ to C#, where C# will fill the arrays with information from a database. Afterwards, the information in the arrays need to be used by C++ (hence the pass by ref).

    However, i've got issues. For some reason, C# only wants to take "SAFEARRAYS" from C++. I've been doing a lot of reading about SAFEARRAYS, but i can't seem to find any information about getting around it -- can someone tell me what is going on, and how (if at all) i can convert from SAFEARRAY to int, double, string and vice versa?

    thanks in advance!

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    A 'plethora' (I've been dying to use that one) of articles canbe found on MSDN (msdn.microsoft.com). That site will be useful for all sorts of .NET related problems.

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    12
    Yes, i've been searching high and low on MSDN, but i can't seem to find what exactly i'm looking for. I've tried this and that, but being a major newbie when it comes to this, i'm not quite able to get any kind of solution. If it helps, i can post my code...even a point in the right direction would be helpful right now...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How To pass 2 dimensional array of strings to a function
    By chottachatri in forum C Programming
    Replies: 15
    Last Post: 01-25-2008, 01:20 PM
  2. pass 3D array
    By gnncj in forum C Programming
    Replies: 3
    Last Post: 07-24-2005, 03:44 AM
  3. pass the pointer of a two dimension array to a function
    By SoFarAway in forum C Programming
    Replies: 8
    Last Post: 04-13-2005, 05:43 AM
  4. Replies: 3
    Last Post: 03-23-2005, 11:22 AM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21