C++/C# Interoperability Type Conversion -


i developing program uses dll driver file. linked dll code have problem 1 method

dll function:

word ndenumdevices(const char* const ** devs); 

i've linked c#

[dllimport("neurobitdrv.dll")]     public static extern ushort ndenumdevices(ref string[] devs); 

as don't have experience c++ dont understand const char* const ** devs means. know sure argument receives array of strings 1 element should 3

and throws out access violation exception

can tell me type should use in c#??


i've worked around it, hardcoded string array device names , works fine :d

const char* const ** devs same const char* const *devs[] be

pointer    array of     constant pointers       constant characters. 

this caused ref (although i'm not sure that). ref array of strings compiled pointer array of strings.

as pointed out in this question, should safe use const char* that.

i think missing length of array. function should declared

word ndenumdevices(const char* devs[], unsigned int length); // c# [dllimport("neurobitdrv.dll")] private static extern ushort ndenumdevices(string[] devs, uint32 length);  public static ushort ndenumdevices(string[] devs) {     ndenumdevices(devs, devs.length); // delegate length } 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -