0

i have mono code

public static unsafe int* mono_method (int* p)
{
//....
return p;
}

and want to call it from native c

MonoObject *result = mono_runtime_invoke(mono_method, NULL, args, NULL);

I tried out some different pointers, variables in the args flag (should be void**)
but always get SIGSEGV error when i execute the runtime invoke.

My question is: Is it possible to pass pointers from c to mono via runtime_invoke and how?

best regards.

Gobliins
  • 3,848
  • 16
  • 67
  • 122

2 Answers2

1

You may have tested everything except what the documentation says at http://www.mono-project.com/Embedding_Mono: The params array contains the arguments to the method with the same convention: MonoObject* pointers for object instances and pointers to the value type otherwise.

void* args[1];
int val = 10;
MonoObject *result;
args [0] = &val;
result = mono_runtime_invoke(mono_method, NULL, args, NULL);
/* result will be a boxed IntPtr since pointer types can't be boxed themselves */
lupus
  • 3,963
  • 1
  • 18
  • 13
  • Hmm, well then the next question would be, is it possible to pass a pointer to function instead of pointer to int and execute the function in the mono code? – Gobliins Dec 15 '10 at 08:02
0

This question was just asked here, but take a look this for the answer.

supercheetah
  • 3,200
  • 4
  • 25
  • 38