[Mono-list] Mono Embedding: manage events

Ing. Francesco Carsana francescocarsana at ds4.it
Thu Apr 3 12:47:53 EDT 2008


Thank you for the example Robert!

 >    // call AttachEvent(session);
 >    args [0] = session;
 >    mono_runtime_invoke (attach_event_method, NULL,
 >           args, &exception);

In this piece of code, what's the type of session?
Is it a MonoObject* ?
I've tried this:

   MonoObject*   session;
   MonoAssembly* assembly;
   MonoClass*    klass;
   MonoObject*   session;
   MonoDomain*   domain;
   MonoImageOpenStatus status; 

   domain = mono_jit_init("session.dll");
   assembly = mono_assembly_open("session.dll", &status);
   klass = mono_class_from_name(mono_assembly_get_image(assembly),
                                "namespace", "Session");
   session = mono_object_new(domain, klass);
   mono_runtime_object_init(session);
 
   mono_add_internal_call("ConnectionEventWrapper::UnmanagedHandler",
                      &icall_ConnectionEventWrapper_UnmanagedHandler);

   gpointer args[1];
   args[0] = session;
   mono_runtime_invoke(attach_event_method, NULL,
                       args, &exception);

Is it right?
In this way I can't catch the event in C++:
it compiles but it doesn't work.
The Session class in session.dll raise the event but
the function icall_ConnectionEventWrapper_UnmanagedHandler is
never called...
Is there something wrong?

Thank you.

Francesco.



More information about the Mono-list mailing list