Ant: Re: Ant: Re: Ant: Re: [Gtk-sharp-list] gtk-sharp.dll not working on linux because it references win32 dll's

Jonathan Pryor jonpryor at
Tue Jul 19 19:44:35 EDT 2005

On Tue, 2005-07-19 at 19:26 +0200, Jost Boekemeier wrote:
> Hi,
> > 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.
> Why do I need that?  I want to load the library that
> the user has placed into his lib directory.  I don't
> care for the version and other things as there can be
> only one such library.

I think we need some clarification. :-)

Ever since Mono 1.0 (if not earlier), Gtk# has been installed into the
GAC.  The only exception to this is under .NET, where a GAC installer
didn't appear until later.

For any assembly, if you want to load it from the GAC you need a
fully-qualified assembly name (name, version, culture, public key
token).  Otherwise, you can just place your assembly into the
appropriate directory and just Assembly.Load() the name.

Thus the question: how are you using, shipping, and installing Gtk#?
Are you using the one included with Mono?  Then it's in the GAC.

Are you copying the Gtk# assemblies into your applications directory?
Then an Assembly.Load() will work.

> > > 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 
> Depends on how you do it.  I think it should be
> possible to check the platform, load the real dll once
> and then this dll takes over.

I know of no way to do that.  The DllImport attribute doesn't allow you
to specify which platform the library corresponds to, so you only have a
few options:

  - Use the same library name on all platforms (not always possible).
  - Use Mono's <dllmap/> functionality (preferred).
  - Conditional compilation (means you cannot copy an assembly between 
  - Duplicate DllImports (one/platform) and a runtime check to select
    which set of imports to use. (ugly!  but useful if the actual
    method imports vary between libraries.  useful for abstraction

You can't "check the platform, load the real dll once and then this dll
takes over" as it wouldn't work.  .NET will LoadLibrary() the specified
library and GetProcAddress() the requested symbol.  If the library
doesn't have the symbol, too bad -- EntryPointNotFoundException.
Similarly, Mono will dlopen() the specified library and dlsym() the
symbol, with no way for one library to masquerade as another.

There's no portable way to intercept and modify this process.

See also:
> > Instead, mono supports .config files for .dll
> > assemblies (.NET doesn't).
> As I understand it, a linux user must place a dll/map
> pair into his library directory, while the windows
> user can simply copy the gtk-sharp dll's, right?

The user shouldn't need to worry about assemblies, much less the .config
files.  Those are a development and deployment issues, handled by the
developer and packager.

All the user needs to do is copy the application directory (and
everything inside it).  Period.

 - Jon

More information about the Gtk-sharp-list mailing list