Il 30/12/2011 19:31, simon rupar ha scritto:
Hey Flippo
I'm also trying to connect C# with gretl api. My P/Invoke signature is
like so
[DllImportAttribute(Constants.gretlLibraryPath, EntryPoint =
"gretl_read_native_data", CallingConvention = CallingConvention.Cdecl)]
public static extern int gretl_read_native_data(string fileName, ref
Structures.DATASET dataset);
you have to mind that callingConversation must be Cdecl.
Besides you have to marshal DATASET, like so
// Call Gretl Api new dataset
IntPtr pointer = GretlCore.NativeGretl.Methods.datainfo_new();
// Marshal pointer to dataset
Structures.DATASET dataset =
(Structures.DATASET)Marshal.PtrToStructure(pointer,typeof(Structures.DATASET));
You can also try to call directly IntPtr.
Hope this helps.
LP Simon
Hello Simon and thank you for your answer!
Following your hint has been useful for me ... but the problem is not in
the CallingConvention setting: I found (finally) the solution just
removing the CharSet setting in the P/Invoke signature of
gretl_read_native_data method.
About this point I have to add some details:
1. In the code excerpt I had reported in my msg, CharSet was set to
CharSet.Unicode ... the code doesn't work also using CharSet.Auto
2. A similar code (with CharSet=CharSet.Auto) has been run successfully
using a Linux machine (system info's: "gretl 1.9.5 - build date
2011-09-11" on "Linux 3.0.0-14 x86_64")
Regards Filippo.