[Mono-dev] Marshalling (Segmentation fault)

Abir Bhattacharya abirb at 2pirad.com
Thu Oct 11 06:31:29 EDT 2007


Hi All,

 

I have a 'C' structure which needs to be marshalled in MONO.

 

The 'C' struct is something like :

 

struct fgrab {

            int bufferlength;

            unsigned char *buffer[1000];

} typedef fgrab_struct;

 

 

In the Mono side I have the following code : 

 

 

Class A

{

            [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]

      Struct ImgStruct

{

      Public uint bufflen;

      IntPtr imgbuff;

}

 

[DllImport ("lib.so")]

Private static extern ImgStruct gbuffergrab(); // gbuffergrab is the 'C'
method which returns type struct

 

 

Public void A()

{

      ImgStruct I;

      I=gbuffergrab();  // ERROR

}

}

 

 

 

The code does not have compilation issues but while execution it gives
"Segmentation Fault " and exits abnormally ..

 

Any help is appreciated.

 

Thanks 

 

Abir

 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071011/d8b72c0c/attachment.html 


More information about the Mono-devel-list mailing list