How to pass structure from C# to ActiveX function created in C++ (MFC) -



How to pass structure from C# to ActiveX function created in C++ (MFC) -

i've unusual problem:

the mfc construction

#define sensor_desc_len 30 #define cam_id_len 20 typedef struct { unsigned int sensortype; char desc[sensor_desc_len]; unsigned int commtype; // usb or tcp - comm_type float firmwareversion; float hardwareversion; int width; int height; int activestartx; int activestarty; char cameraid[cam_id_len]; unsigned int pcam; char color; } camera_cap_api;

the corresponding c# construction is:

[structlayout(layoutkind.sequential)] public struct camera_cap_api { public uint sensortype; [marshalas(unmanagedtype.byvalarray, sizeconst = 30)] public byte[] desc; public uint commtype; public float firmwareversion; public float hardwareversion; public int width; public int height; public int activestartx; public int activestarty; [marshalas(unmanagedtype.byvalarray, sizeconst = 20)] public byte[] cameraid; public uint pcam; public sbyte color; } ;

it is right - can pass construction through dll using next signature:

[system.runtime.interopservices.dllimport("camelot.dll", entrypoint = "camgetcamcaps", exactspelling = true, charset = system.runtime.interopservices.charset.ansi, setlasterror = true)] public static extern int camgetcamcaps(int ncamnum, ref camera_cap_api cameracap);

the problem in activex. (mfc)

i create parameter variant. , shows object in c# side. trying pass same construction object fails:

object c = new camera_cap_api(); camera1.getcamcaps(ref c); // camera1 activex command

i next error: unhandled exception of type 'system.argumentexception' occurred in mscorlib.dll

additional information: value not fall within expected range.

i've tried:

intptr ptr = marshal.alloccotaskmem(200); getnativevariantforobject... without success.

i same error.

what problem?

c# c++ mfc activex

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -