[Mono-dev] Marshalling a struct inside a struct

Dudemullet elpaip at gmail.com
Thu Dec 11 23:33:33 EST 2008


I have a struct that looks like this 

 ++ Unmanaged struct ++

typedef struct {
    GList *tracks;
    GList *playlists;
    gchar *filename;    
    Itdb_Device *device;
    guint32 version;
    guint64 id;

    guint64 usertype;
    gpointer userdata;

    ItdbUserDataDuplicateFunc userdata_duplicate;
    ItdbUserDataDestroyFunc userdata_destroy;
} Itdb_iTunesDB;


and I have a function inside a dll that is gonna populate it and Ive tried
various ways to declare  the return type either by IntPtr and later using
Marshal.PtrtoStructure but when I try and use this function I get the error 
"The structure must not be a value class".

this is how I tried to implement my function

  ++ function ++

   static extern itdb itdb_parse(string mp, IntPtr ge);

 itdb database = itdb_parse("G:", IntPtr.Zero);


In the source I can see that "itdb_parse" returns a Itdb_iTunesDB pointer so
maybe I could use classes but what about the Itdb_Device struct that inside
this struct ? Also if I need to implement the class, what should I do  Any
suggestions ?

Thank you

View this message in context: http://www.nabble.com/Marshalling-a-struct-inside-a-struct-tp20969792p20969792.html
Sent from the Mono - Dev mailing list archive at Nabble.com.

More information about the Mono-devel-list mailing list