Ant: Re: Ant: Re: [Gtk-sharp-list] gtk-sharp.dll not working
on linux because it references win32 dll's
Jonathan Pryor
jonpryor at vt.edu
Mon Jul 18 21:10:48 EDT 2005
On Mon, 2005-07-18 at 21:03 +0200, Jost Boekemeier wrote:
> Hi,
>
> it's a simple:
>
> System.Reflection.Assembly.load("gtk-sharp);
That's unlikely to work, as gtk-sharp is now in the GAC and the assembly
name you're providing lacks version information and other things.
Assembly.Load ("foo") will only load foo.dll from the
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase
directory (and PrivateBinPath, PrivateBinPathProbe, and other similar
directories).
In short, Assembly.Load ("gtk-sharp") WILL NOT WORK, and hasn't worked
ever since gtk-sharp.dll was placed in the GAC.
To load an Assembly located in the GAC, you need either
Assembly.LoadWithPartialName (which might not load the assembly you
want, and is [Obsolete] in .NET 2.0) or Assembly.Load (AssemblyName).
MSDN should have some examples for you.
> However, I don't understand why gtk-sharp doesn't
> simply reference a bridge dll which might select the
> appropriate native dll (windows or linux).
Because writing hundreds (yes, hundreds) of functions that do nothing
more than forward calls to another function are tedious and error-prone
to write and bloat memory requirements. Do you really want a new
library with nothing more than:
ReturnType
gtksharp_gtk_function (Type1 arg1, Type2 arg2)
{
return gtk_function (arg1, arg2);
}
This would eat disk space & RAM for no real gain.
Instead, mono supports .config files for .dll assemblies (.NET doesn't).
These .config files can contain <dllmap/> entries to map a library name
used in a DllImport statement onto a *different* library name at
runtime. This allows the an assembly to use the win32 names everywhere,
and a .config file can be provided so that mono loads the appropriate
library at runtime. This is transparent to the app, and works fine with
Reflection and everything else.
In fact, if you get a DllImportAttribute via Reflection,
DllImportAttribute.Value will contain the remapped library name, *not*
the name that's in the IL (something put to use by mono-shlib-cop).
Best of all, it allows you to ship a single assembly that works on both
mono and .NET without needing conditional compilation & a recompile.
> If one currently looks at gtk-sharp dll (either via
> reflection or via monodis), one sees that a lib*win32
> is needed.
As stated above, when using reflection you get the remapped library
name, not the library name in the IL. Monodis will obviously show you
the library name in the IL (it would be broken to do otherwise).
> So one could come to the conclusion that gtk-sharp only works on
> windows platforms...
One could come to that conclusion, then wonder why there are more Linux
Gtk# apps than Windows ones. :-)
Thus proving that the obvious conclusion isn't always the correct one.
- Jon
More information about the Gtk-sharp-list
mailing list