I have Blah.cs:
public unsafe static int Main()
{
int[] ai = {1, 2, 3, 4, 5};
UIntPtr stai = (UIntPtr) ai.Length;
CManagedStuff obj = new CManagedStuff();
obj.DoSomething(ai, stai);
}
Then ManagedStuff.cpp:
void CManagedStuff::DoSomething(int^ _ai, UIntPtr _stai)
{
pUnmanagedStuff->DoSomething(_ai, (size_t) _stai);
}
And UnmanagedStuff.cpp:
void CUnmanagedStuff::DoSomething(int* _ai, size_t _stai)
{
}
How to transfer int[] aifrom Main to ManagedStuff :: DoSomething? I understand that there is no marshaling in this call because all managed code is managed.
And how can I then marshal int^ _aiin ManagedStuff :: DoSomething to call UnmanagedStuff :: DoSomething? If I had int[] _ai, then the code in the answer for this SO question could help ( C #: Marshalling a "pointer to an array of int" from SendMessage () lParam ).
Alternatively, how can I avoid working with C #, C ++ - interaction, Microsoft and Windows and stop the suffering of the world?
source
share