Forum Xamarin Xamarin.iOS

iOS ARM Build Native Call With Referenced Structure Parameter Issue


static MyStruct stru = new MyStruct();

unsafe void button_clicked(object sender,EventArgs args)
    int a = 0;

        SetStruct1(ref stru);
        SetStruct2(ref stru); //////////////////////////////////////////////// CRASHING HERE
        a =stru.myFunction(4, 5);
        Debug.WriteLine("---> INFO : " + a);

static int sum(int a,int b)
       return a + b;

static int multiply(int a, int b)
       return a * b;

[StructLayout(LayoutKind.Sequential,Pack =1)]
struct MyStruct
        public  func myFunction1;
        public func myFunction2;

public delegate int func(int a, int b);

[DllImport("__Internal", EntryPoint = "setStruct1")]
extern static void SetStruct1(ref MyStruct s);

[DllImport("__Internal", EntryPoint = "setStruct2")]
extern static void SetStruct2(ref MyStruct s);


#include "StaticLibrary1.h"

int structFunc(int a, int b)
    return b * a;

void setStruct1(pmystruct str)
    str->myFunc1 = &structFunc;

void setStruct2(pmystruct str)
    str->myFunc2 = &structFunc;


typedef struct _mystruct
    func myFunc1;
    func myFunc2;
}mystruct, *pmystruct;

extern void setStruct1(pmystruct str);
extern void setStruct2(pmystruct str);
extern  int structFunc(int a, int b);


_Unhandled Exception:

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper native-to-managed) App1.iOS.func:wrapper_aot_native (int,int)' 
``while running with --aot-only. See for more information._

i need help about this issue.

Sign In or Register to comment.