Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Delegate functions
Message
De
11/06/2019 12:50:11
 
 
À
11/06/2019 11:53:02
Information générale
Forum:
C#
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01669003
Message ID:
01669007
Vues:
43
>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);
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform