I have a native C/C++ struct
typedef struct
{
...
} AStruct;
and in C++/CLI code i define one delegate and one cli array as following
public delegate void UpdateDataDelegate(AStruct% aSt,AStruct% bSt);
cli::Array<AStruct>^ args=gcnew cli::Array<AStruct>(2); // complile failed!!!!。
this->Invoke(updateData,args);
AStruct
has many fields and was used by many module开发者_如何转开发s so if i don't like to write a mananged wrap for AStruct
, how to make above code works?
many thanks
The element type of a managed array must be a managed type. One workaround is store pointers:
array<AStruct*>^ args=gcnew array<AStruct*>(2);
args[0] = new AStruct;
// etc...
UpdateDataDelegate^ dlg = gcnew UpdateDataDelegate(Mumble);
dlg->Invoke(*args[0], *args[1]);
精彩评论