Obter uma matriz de estruturas da dll nativa para o aplicativo c #

Eu tenho um projeto C # .NET 2.0 CF em que preciso chamar um método em uma DLL C ++ nativa. Este método nativo retorna uma matriz do tipoTableEntry. No momento em que o método nativo é chamado, não sei o tamanho da matriz.

Como posso obter a tabela da DLL nativa para o projeto C #? Abaixo está efetivamente o que tenho agora.

// 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;
}

Obrigado, PaulH

questionAnswers(1)

yourAnswerToTheQuestion