Managing native struct returned from function called in managed wrapper
-
I have a function in a wrapper DLL that points to a native function. The native function returns a struct and I am looking for a solution to Marshall the struct to be called by C# Winform app. The managed function: M_USB_DEVICE_DESCRIPTOR SXManaged::M_GetDeviceInfo(void) Where: M_USB_DEVICE_DESCRIPTOR is a managed struct that is virutally the same as the native struct SXManaged is the managed class in the wrapper DLL. Inside the managed function I call the native function: usb_dd = umc->GetDeviceInfo(); Where: usb_dd is a native struct variable of type USB_DEVICE_DESCRIPTOR. The members of that are very blittable - bytes and unsigned short. umc is an object that is a pointer to the native class that holds native function GetDeviceInfo() I can't leave the return type as a native struct type as it's being called in C#. I've looked as far as I can to try and see how to do this but coming up short. Any help greatly appreciated. Al
Jer 29:11
-
I have a function in a wrapper DLL that points to a native function. The native function returns a struct and I am looking for a solution to Marshall the struct to be called by C# Winform app. The managed function: M_USB_DEVICE_DESCRIPTOR SXManaged::M_GetDeviceInfo(void) Where: M_USB_DEVICE_DESCRIPTOR is a managed struct that is virutally the same as the native struct SXManaged is the managed class in the wrapper DLL. Inside the managed function I call the native function: usb_dd = umc->GetDeviceInfo(); Where: usb_dd is a native struct variable of type USB_DEVICE_DESCRIPTOR. The members of that are very blittable - bytes and unsigned short. umc is an object that is a pointer to the native class that holds native function GetDeviceInfo() I can't leave the return type as a native struct type as it's being called in C#. I've looked as far as I can to try and see how to do this but coming up short. Any help greatly appreciated. Al
Jer 29:11
Native struct and managed struct is different. Your best bet would be to create a managed class with necessary details and fill it with the values from native function. This instance can be consumed from C#.
Best Wishes, Navaneeth
-
Native struct and managed struct is different. Your best bet would be to create a managed class with necessary details and fill it with the values from native function. This instance can be consumed from C#.
Best Wishes, Navaneeth
-
The "managed" function shown in the illustration IS from a managed class. :confused:
Jer 29:11
Well, your return type is
M_USB_DEVICE_DESCRIPTOR
which is a managed type, right? If yes, what is the problem ate you facing in using it from C#?Navaneeth How to use google | Ask smart questions
-
Well, your return type is
M_USB_DEVICE_DESCRIPTOR
which is a managed type, right? If yes, what is the problem ate you facing in using it from C#?Navaneeth How to use google | Ask smart questions