ios - Can't marshal a structure from an unmanged library to managed code in monotouch -


I have a structure that is defined in the header file for the library that a vendor has given us.

  Type -File {int iLen; Int iType; Int state; Unsigned four data [1200]; } TCIDCMDRPS;   

I have created a structure in C # which I think matches it.

  [Layout layout (LayoutCind.Secure)] Public structure TCIRED CMDRSpend {public INLN; Public IITIP; Public inter state; Public byte [] data; }   

I have a few points mentioned here. I am not sure why one should map an unsigned char array I initially had guessed that the unsigned char should be described all around, but in C # there is a Ciconicode, so it does not seem that it will work. I also tried to mapping it in one byte. I do not even know that length would be important for the 1200 marchler and if so, how to assign it.

I have the following method in a monochach app that takes the form of a parameter. / P>

  [export ("OnRecvData:")] Public is brought by the library via the TCardCmdRespond response {...}   

method Selector The method is applied without any problem. The problem occurs when I look at the data contained in the structure. This number is very high when I'm expecting to be in the range between 1-3 (comparative purpose-c code shows iType in this category). I tried to reverse the byte order using bit-converter, if this is an endurance problem, which Marshall has not solved for me, the numbers are still high so I think the problem is beyond simple endlessness.

Further problems arise when I try to drag data out of four arrays. It is not empty, but trying to access it in any way beyond the investigation of a null, which crashes the application with an EXC_BAD_ACCESS (SIGABRT)

My solution is to solve this purpose Instead, write a cover instead, make a different structure in the parameters then a library that wrap it up and bind it instead. My purpose-c skills are not so hot and this is a slow process.

Is there any way I can work it without wrapping it in Objective-Library?

Your C # definition is wrong.

The C version contains inline blocks for 1200 bytes of array, while your C # version contains an indicator for an array (4 bytes).

You can see it:



Comments