[Mono-list] Assertion when accessing C library
Robert Jordan
robertj at gmx.net
Sun Mar 29 15:29:12 EDT 2009
This is already fixed in SVN.
Robert
Ben Henderson wrote:
> I posted a question on this assertion a few days ago with no response. Not
> sure about your case, but I was trying to send a native function pointer
> into a native function via p/invoke. I was receiving the same assertion
> which looks to me that it doesn't like the managed delegate wrapping a
> p/invoke function. I worked around the issue by marshaling a managed
> delegate for the function pointer parameter in the native function and then
> calling the native function from the managed delegate. (Hope this makes
> sense!) I'll post sample code below. If you are getting this assertion in
> a different scenario, please post some code. Also, I am going to submit a
> bug on this, as the MS CLR has no problem marshaling the native function
> pointer.
>
> Ben
>
> using System;
> using System.Runtime.InteropServices;
>
> namespace FunctionPointerInterop
> {
> class Program
> {
> [DllImport("testdll.dll")]
> public extern static void foo();
>
> [DllImport("testdll.dll")]
> public extern static void bar(foo_delegate foo);
>
> public delegate void foo_delegate();
>
> static foo_delegate my_foo_delegate;
>
> static void ManagedFooDelegate()
> {
> foo();
> }
>
> static void Main(string[] args)
> {
> my_foo_delegate = new foo_delegate(ManagedFooDelegate);
> bar(my_foo_delegate);
> }
> }
> }
>
>
> rumcajz wrote:
>> Anyone has any idea what this assertion is supposed to mean:
>>
>> ERROR:marshal.c:9235:mono_marshal_get_managed_wrapper: assertion failed:
>> (!mono_method_signature (method)->pinvoke)
>> Stacktrace:
>>
>> at (wrapper managed-to-native)
>> object.__icall_wrapper_mono_delegate_to_ftnptr (object) <0x00045>
>> at (wrapper managed-to-native)
>> object.__icall_wrapper_mono_delegate_to_ftnptr (object) <0xffffffff>
>>
>> Thanks.
>>
>
More information about the Mono-list
mailing list