[Mono-list] Assertion when accessing C library

Ben Henderson bhenderson at ipswitch.com
Mon Mar 23 07:40:13 EDT 2009

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


using System;
using System.Runtime.InteropServices;

namespace FunctionPointerInterop
    class Program
        public extern static void foo();

        public extern static void bar(foo_delegate foo);

        public delegate void foo_delegate();

        static foo_delegate my_foo_delegate;

        static void ManagedFooDelegate()

        static void Main(string[] args)
            my_foo_delegate = new foo_delegate(ManagedFooDelegate);

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.

View this message in context: http://www.nabble.com/Assertion-when-accessing-C-library-tp22657063p22658516.html
Sent from the Mono - General mailing list archive at Nabble.com.

More information about the Mono-list mailing list