Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delegate functions
Message
From
11/06/2019 12:50:11
 
 
To
11/06/2019 11:53:02
General information
Forum:
C#
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01669003
Message ID:
01669007
Views:
42
>I have been able to get it closer using this:
>
>[DllImport("my.dll")]
>public static extern UInt32 dbf_build_recno_list__by_callback(Int32 handle, UInt32 builderRootAddress, [MarshalAs(UnmanagedType.FunctionPtr)] MyClass.myCallback testCallback, [MarshalAs(UnmanagedType.LPStr)] string param);
>
>[UnmanagedFunctionPointer(CallingConvention.Winapi)]
>unsafe delegate bool myCallback(UInt32 handle, UInt32 record, void* pParam);
>
>unsafe static myCallback cb = (p1, p2, p3) =>
>{
>    return true;
>};
>
>public MyClass()
>{
>    string t = "";
>
>    UInt32 result = dbf_build_recno_list__by_callback(5, 5, cb, t);
>}
>
>
>It's gives me the error:
>"Inconsistent accessiblity: parameter type "MyClass.myCallback' is less accessible than method 'MyClass.dbf_build_recno_list__by_callback(int, uint, MyClass.myCallback, string)' "

I have found the solution. I needed to change this:
>[DllImport("my.dll")]
public static extern UInt32 dbf_build_recno_list__by_callback(Int32 handle, UInt32 builderRootAddress, [MarshalAs(UnmanagedType.FunctionPtr)] MyClass.myCallback testCallback, [MarshalAs(UnmanagedType.LPStr)] string param);
To this:
>[DllImport("my.dll")]
// Remove public
static extern UInt32 dbf_build_recno_list__by_callback(Int32 handle, UInt32 builderRootAddress, [MarshalAs(UnmanagedType.FunctionPtr)] MyClass.myCallback testCallback, [MarshalAs(UnmanagedType.LPStr)] string param);
Previous
Reply
Map
View

Click here to load this message in the networking platform