[Mono-list] NullReferenceException when calling thunk
Robert Jordan
robertj at gmx.net
Wed Jan 23 19:57:51 UTC 2013
On 23.01.2013 20:32, tomason wrote:
> However, when I run that, I get an EntryPointNotFound exception. I put an
> extern "C" block around my native_RegisterObject, but that didn't help.
>
> In C#, this is how I declare the native function:
>
> private delegate float AddDelegate(float a, float b);
>
> [DllImport("__Internal", EntryPoint="native_registerObject")]
> private static extern void native_registerObject(MainClass instance,
> AddDelegate add);
>
> And then I call that as above.
>
> Can I use internal calls for registering a delegate? If not, how do I
> expose my native functions such that the runtime can find them in the image
> that's running?
Yes, 'extern "C"' is a must. You may need to add
-Wl,--export-dynamic
to your cflags when compiling the main program. This will instruct
the linker to export all public symbols as if the program where
a library.
Robert
More information about the Mono-list
mailing list