Again pb with Gdal raster reading

Feb 11, 2009 at 3:28 PM
I've downloaded latest trunk yesterday and found SharpMap a great software. Thanks for mainting it !
I tried the raster reading part with the extension GdalRasterLayer.
Visua Studio 2005 built ok and put many dll in the exe folder (I only referenced SharpMap.Extensions.dll built from latest source, and it put automatically all other dlls. I supposed it found them in trunk\SharpMap.Extensions\bin\Debug)

When I launch the program :

      String filename = "sample_geotiff.tif";
      GdalRasterLayer raster = new GdalRasterLayer("image",filename);

then I have the  error : 

An unhandled exception of type 'System.TypeInitializationException' occurred in gdal_csharp.dll
Additional information: The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception.

Which is in GDAL.Gdal.AllRegister().

I also tried to replace the dlls with the one from FWTools but it did not change (actually they looked more recent in SharpMap)
Thanks for any help.
Riccardo.

Coordinator
Feb 11, 2009 at 4:52 PM
Hi Ricardo, You need to ensure that all the dlls are present in the bin directory  - even the unmanaged ones (they are in the ExternalReferences\ReferencesforSharpMap.Extensions directory ) hth jd
Feb 11, 2009 at 8:47 PM
Hi John , and thanks for your help.
I copied in my project/bin/debug the 15 items that are in ReferencesforSharpMap.Extensions directory, and it replaced only 9 items already present. I suppose that visual studio did not copy every needed dll.
But actually it did not change. I tried to rebuild the full test and launch the program from the windows explorer instead of VS, no change.

the geotiff is a small image that loads correctly in UDIG. Maybe shall I try another file, but where can I find regular geotiff ?

Thanks for any new idea.
Riccardo.
Feb 12, 2009 at 1:01 PM
Make sure you copy ALL dll's from the bin folder in fwtools to your debug folder.  I don't know why that GdalPINVOKE is such a never ending hassle.
Feb 12, 2009 at 1:42 PM
Hello
I copied all dlls from fwtools/bin and it works now (I was copying only those from fwtools/csharp). It seems that I'm not the only one to read forums too quickly. Thanks a lot.
Feb 12, 2009 at 5:48 PM
Just to clarify, I didn't mean people asking about it was a hassle.  The GdalPINVOKE bug keeps popping up, and I haven't found a solution to fix it that works for everyone...besides copying every dll from fwtools, which seems unnecessary.  The hassle was not directed at you :)
Feb 12, 2009 at 7:00 PM
Don't worry, I didn't took it for me. 
And I beleive that the solution is to select which dll is needed for the sample to work.
Thanks for your time.