Creating data binding in managed code used by unmanaged code -
12-30-2007
, 04:30 PM
I have some existing classes written in C++ used to read PLC data. The
classes using some cind of data binding that looks like OLE-DB with an array
of structs. The data binding is done by using the C++ offsettof macro and the
classes using this information to calculate the address to each members of
the structs in the array.
I need to create a result set based on managed array of struct or datasets,
tell the existing classes how the structs looks like and indirectly writing
data to the members in the managed structs. I did some test with the
GCHandle::Alloc and GCHandle::FromIntPtr functions but are not able to
dynamically create pointers or handles in managed code because the IntPtr
does not impement the == operator.
Is it possible to do this? If so, where can I found samples. I using Visual
Studio 2005 and C# for the managed code and C++ for the unmanaged part. The
marshaling is supposed to be developed in C++. |