[Mono-dev] Mixed Mode Assemblies

Robert Jordan robertj at gmx.net
Sat Jul 9 08:05:32 EDT 2011


On 09.07.2011 12:20, Quandary wrote:
> It's true that p/Invoke + InterOp services do not form a complete solution.
> However, creating a interface in managed code across platforms isn't
> very difficult.
>
> All you need to do is to pack a x86&x64&ARM&PPC Linux&Windows&Mac
> version of the native dll into the .NET dll's ressources, then stream
> the respective assembly out on the calling of the constructor, and
> create an abstract class, where you create an instance for the
> respective platform (for example because of structs, where on x64, there
> are different sizes of long + int on Windows&  Linux/UNIX), which you
> can then invoke as an interface.

Extracting and loading native libraries at run-time won't work
correctly on sane systems, unless you somehow manage to (1)
extract them into a path already configured as a library path,
(2) using absolute paths in DllImport attributes, (3) generating
DllImport code at run-time or (4) loading the libs and their
exports w/out DllImport's help (dlopen, LoadLibrary etc.).

That's why nobody is using such an approach in real world,
at least not under Unix. Using <dllmap> or a starter shell
script that sets the LD path is by far less complex (a
matter of minutes to develop).

Robert



More information about the Mono-devel-list mailing list