[Mono-list] interop delegate/callback problem

Bob Smith bob@thestuff.net
Tue, 13 Nov 2001 13:19:38 -0500 (EST)


I beleave I saw somewhere in the microsoft documentation that a delegate
gets pined on the first call to a c function and then is unpined on the
first time the delegate gets called by the c function. This meens that if
the c function calls the delegate a second time, the delegate might have
been moved by the garbage collector after the first call. I think you have
to explicitly pin the delegate if you want the delegate to work for things
that need to call the callback multiple times like GTK Signals.

On Tue, 13 Nov 2001, Lloyd Dupont wrote:

> Hello fellow users !
> Any who wants to look at my bug ?
>
> i create a C struct with some function pointer (in fact C# delegate)
> and reference it in C# as an IntPtr.
>
> later i execute some interop function taking my struct as an argument
> and calling my function pointer.
> strangely, after a few call, there is strange error, such as (most
> curious) NullReferenceException when returning from my C# delegate
> callback to my C code....
>
> i join you my project so you could test....
> anyone has any idea ?
>