[Mono-list] Why InternalCall rather than DllImport?

Dick Porter dick@ximian.com
Wed, 9 Jan 2002 16:32:53 +0000


On Wed, Jan 09, 2002 at 08:20:10AM -0800, Matt Kimball wrote:
> So, I'm looking at the Linux.cs implementation, and I'm wondering why most of
> the file I/O methods implemented there are using InternalCall methods, rather
> than using the Wrapper methods defined in libmonowrapper.so.  Using the Unix
> Wrapper class would seem to be a cleaner approach.  Is there a reason for doing
> the former?  Or would it be kosher to implement some of the missing methods
> using the Wrapper methods, as in the attached patch?

The file IO routines need to emulate w32 handles somehow.  Currently, we're
emulating w32 IO in the io-layer library and accessing it with internal calls.
This gives us simpler C# classes (because they tend to match w32 calls) and
cross-platform compatibility (in theory, i dont think anyone has tried it
out yet.)

DllImport sucks badly if you care about compatibility.  For example, Ive
just been cleaning up the System.Net.Dns class which tried to DllImport
from the cygwin1 library.  It also gives you large amounts of pain coping
with unicode conversions.

- Dick