[gdal-dev] using OGR/OSR from C# - where to put the dependent DLLs?

Mark Cheyne cheynm at yahoo.com
Tue Dec 11 11:04:29 EST 2007


Hello - I'm sure this is a common question, but I
haven't found a definitive treatment on the OGR
website or in the GDAL mailing list archives.

I'm working on a C# app on Windows that does
coordinate transformations using the
OSGeo.OSR.SpatialReference class. My app references
osr_csharp.dll.

Bottom line, what do I need to do so that the DLLs
that osr_csharp.dll is dependent on are available at
run-time?

Only if I copy all 61 DLLs found in C:\Program
Files\FWTools2.0.0\bin to my app's directory does my
app work. However, for a variety of reasons,
especially unit testing, I'd prefer to find an
alternative, if one exists.

I've seen
http://trac.osgeo.org/gdal/wiki/GdalOgrCsharpUsage and
http://trac.osgeo.org/gdal/wiki/GdalOgrInCsharp which
say that adding C:\Program Files\FWTools2.0.0\bin\ to
my PATH env var is enough - nope. 

I've seen somewhere that I could copy all 61 DLLs
found in C:\Program Files\FWTools2.0.0\bin to my
System32 directory - that doesn't work either.

If the dependent DLLs are not found, at runtime I get
the following exception when I call the
SpatialReference constructor: "The type initializer
for 'OSGeo.OSR.OsrPINVOKE' threw an exception.". The
innermost exception is what you'd expect -
"System.DllNotFoundException: Unable to load DLL
'osr_wrap': The operating system cannot run."

Thank you, Mark

Mark Cheyne
(608) 332-2235 (cell)


      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


More information about the gdal-dev mailing list