[Mono-dev] PInvoke and language interopelability

BGB cr88192 at hotmail.com
Tue Jan 13 13:20:15 EST 2009


  ----- Original Message ----- 
  From: Alfredo José Muela Romero 
  To: Bill Holmes 
  Cc: mono-devel-list at lists.ximian.com 
  Sent: Wednesday, January 14, 2009 2:37 AM
  Subject: Re: [Mono-dev] PInvoke and language interopelability


  2009/1/13 Bill Holmes <billholmes54 at gmail.com>

    Alfredo,

    I may not fully understand the problem.  Are you simply asking how to
    call back into C# from C++?

    We use 2 different approaches.

    Function pointers.  If you pass a C# delegate through the PInvoke
    layer C++ will view that as a function pointer.

    COM Interop.  (Only supported on Windows and Linux.) This allows you
    to marshal a Managed object to C++ which then can call methods on that
    objects' interface(s).

    -bill


  Hi Bill, 

  Yes, your right that's my problem in the simplest words. Sorry not to have explained it so easily :)

  I guess I'm in your second case, since the extern method (the one in the C++ library) can't be redefined to receive a function pointer instead of a object pointer.

  Where could I find some examples / info about the solution you talked about?

  What do you think about the tunned proxy class to get it done with delegates? With that approach I would get more software architectures in the scope, wouldn't I?



may or may not matter, but a lot of this falls outside the confines of ECMA-335...


second:
is it not possible to wrap the method to accept what you can give it?...


sadly, I am not sure what mono's C (or C++) level API is like, how it passes objects, or what APIs might be provided for interfacing with objects from C land. but, oh well, the people around here can maybe give info, as I am left wondering some as well.

actually, I guess one possiblity (if it works "in general"), could be to look into IKVM, which could potentially give a JNI interface, which could allow getting at the objects contents, invoking methods, ...

as noted above, COM is another approach (maybe preferable?...).


sadly though, all of this would require wrapping the method in question in one way or another, and I have not personally looked into any of this (actually, as of yet, I have not been able to successfully build mono on my system... which doesn't help some with my "confidence" in the project... but alas part of my complaint is the dependency on glib, not-so-pretty code composing its innards, ...).

however, a part of the issue is that non-trivial interaction with native C++ code can get hairy...

or such...


but, in any case, best of luck...





------------------------------------------------------------------------------


  _______________________________________________
  Mono-devel-list mailing list
  Mono-devel-list at lists.ximian.com
  http://lists.ximian.com/mailman/listinfo/mono-devel-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090114/f0abe043/attachment-0001.html 


More information about the Mono-devel-list mailing list