Obtenga una variedad de estructuras de dll nativo a la aplicación C #

Tengo un proyecto C # .NET 2.0 CF donde necesito invocar un método en una DLL C ++ nativa. Este método nativo devuelve una matriz de tipoTableEntry. En el momento en que se llama al método nativo, no sé qué tan grande será la matriz.

¿Cómo puedo obtener la tabla de la DLL nativa al proyecto C #? Debajo está efectivamente lo que tengo ahora.

// in C# .NET 2.0 CF project
[StructLayout(LayoutKind.Sequential)]
public struct TableEntry
{
    [MarshalAs(UnmanagedType.LPWStr)] public string description;
    public int item;
    public int another_item;
    public IntPtr some_data;
}

[DllImport("MyDll.dll", 
    CallingConvention = CallingConvention.Winapi, 
    CharSet = CharSet.Auto)]
public static extern bool GetTable(ref TableEntry[] table);

SomeFunction()
{
    TableEntry[] table = null;
    bool success = GetTable( ref table );
    // at this point, the table is empty
}


// In Native C++ DLL
std::vector< TABLE_ENTRY > global_dll_table;
extern "C" __declspec(dllexport) bool GetTable( TABLE_ENTRY* table )
{
    table = &global_dll_table.front();
    return true;
}

Gracias PaulH

Respuestas a la pregunta(1)

Su respuesta a la pregunta