[Mono-list] Mono Embedding: invoking methods

Ing. Francesco Carsana francescocarsana at ds4.it
Mon Apr 7 04:13:59 EDT 2008


I'm working with Mono Embedding and I'm trying
to invoke this CIL method from C:

    public static void AttachConnectEvent(Session _s);

where Session is a class:

    public sealed class Session

       public static void AttachConnectEvent(Session _s);

I write this C code to inkove AttachConnectEvent:

    MonoDomain *domain;
    MonoAssembly *assembly;
    MonoImageOpenStatus status;
    MonoClass *klass;
    MonoObject *object;
    MonoMethod* attachConnectEvent;

    domain = mono_jit_init("Session.dll");
    assembly = mono_assembly_open("Session.dll", &status);
    klass = mono_class_from_name(mono_assembly_get_image(assembly),
                                 "Session", "Session");
    object = mono_object_new(domain, klass);

    attachConnect = mono_class_get_method_from_name(klass,
                     "AttachConnectEvent", 1);

    gpointer args[1];
    args[0] = object;
    mono_runtime_invoke(attachConnectEvent, NULL, args, NULL);

Is it correct?
In particular, is it rith to assign args[0] = object?

Thank You.


More information about the Mono-list mailing list