[Mono-dev] gdal/mono/linux; Native bindings, PInvoke, and tracking TypeLoader exceptions

Floris Briolas mono_nabble at briolas.nl
Tue Nov 4 04:28:22 EST 2008

fevans wrote:
> *trim*
> So when I run the command 'mono GDALInfo.exe' it returns a usage
> statement. no errors. But when I run 'mono GDALinfo.exe foo.tif', I get a
> type-loader exception.
> *trim*

This is a yes, me too response, but I've done some analysis on my own. 

First I was stuck on the DllNotFoundException. My next step was to call
GDALAllRegister on gdal_fw (Gdal_wrap uses this one).
(*All code was not cut and pasted*)

public static extern void GDALAllRegister();

And created a small console app that runs this. When run from command line
it runs just fine, but when run with mono it gave a DllNotFoundException
(startled). The DLL could be found just fine, the environment path was the
same, it pointed to the bin of gdal (I've used fwtools 2.2.8) ,.. so what
could have gone wrong?

I've PInvoked LoadLibrary from Kernel32

[DllImport("Kernel32"), SetLastError = true)]
Public extern static int LoadLibrary(string name);

When you run :
With normal .net it runs fine, a handle is returned. under mono it fails
with error code (getlasterror) 182 meaning invalid ordinal? 
I've checked the dll dependencies of gdal_fw,.. and long story short, it
seems the ssleay32.dll fails to load (182) when mono is run. The
dependencies of ssleay32 load just fine. btw folks these are all unmanaged

Now it's time for me to give up. Hoping someone finds a solution, or an
explanation why this would occur with mono running.


Floris Briolas

(used mono 2.0.1 on win xp)
View this message in context: http://www.nabble.com/gdal-mono-linux--Native-bindings%2C-PInvoke%2C-and-tracking-TypeLoader-exceptions-tp17622978p20318829.html
Sent from the Mono - Dev mailing list archive at Nabble.com.

More information about the Mono-devel-list mailing list