[Mono-list] Interop

John Lenz lenz@cs.wisc.edu
Tue, 14 Dec 2004 18:40:48 +0000


On 12/14/04 09:50:55, Javier Miguel Gonzalez wrote:
> > > I want to call a .Net function (in a class) from unmanaged
> > code, like VC+
> > > +
> > > 6
> > > or Delphi 7.
> > >
> > > Do you know if it is possible?
> > >
> > > Are there something like JNI in .Net?
> > >
> > > I have read this articles:
> > >
> > >
> > http://www.blong.com/Conferences/BorCon2004/Interop1/Win32AndD
> otNetInterop.h
> > tm#InversePInvoke
> >
> > http://www.codeproject.com/csharp/Win32_to_NET.asp
> >
> > ...but I feel that this methods are not so much standard.
> >
> > Are in Mono something better to do it than in MS .Net Framework?
> 
> > You could also check out SWIG at http://www.swig.org, which has C# support
> > and works with the Microsoft runtime, mono, and Portable.NET.  There are a
> > lot of examples on wrapping code provided by SWIG as well.
> >
> > John
> 
> Will Swig allow a VB6 or Delphi7 developer call a function within a managed
> dll/so library?
> 

I don't actually know about C#, but I assume so.  I use SWIG for the
guile and python languages, and it allows C code to call into guile
and python code.  I assume C# wouldn't be any different.  If you can,
I would go with SWIG since it automates all that repetitive code you
need to write.

I am almost certain that you are going to need to call 
Delphi or VB6 -> C -> C#
and SWIG would take care of the C -> C# part.

By the way, SWIG uses PInvoke.  SWIG is just a tool that generates 
all the Pinvoke code for you, so you don't need to write it yourself.

John