Finding a GDAL library for a custom Add-in

2109
4
04-28-2010 08:34 AM
RonVincent
Occasional Contributor
I've written an Add-In that mosaics CADRG layers. It works fine in a test Console app but only because I've placed the GDAL libraries with the main program's exe. However, if I run this same code with AGX it isn't finding the GDAL libraries and errors with this message:

"The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception.
System.DllNotFoundException: Unable to load DLL 'gdal_wrap': The specified procedure could not be found.

I've tried placing the libraries (including gdal_wrap.dll) in my Debug and Release locations and I've tried placing the libraries in the Add-in's location and in the bin directory of AGX and it errors no matter what.

Where do I place this DLL? Any help is appreciated.

Ron
0 Kudos
4 Replies
MarcN
by
New Contributor III
Currently I do not understand your problem. Maybe you can provide some more informtaion on what you want to do.
0 Kudos
AnthonyGrescavage
New Contributor III
I am currently dealing with the same issue. I have used the sysinternals suite to trace the issue.  While I have not specifically found the problem, I am getting closer.  I have determined that gdal IS finding the dll's that are located in the directory with it.  This has been verified using the procmon utility.  I suspect the problem is a "dll hell" issue.  Some of the dlls that come gdal requires are also used by ArcGIS explorer.  Many of these dlls are different versions than the ones gdal is using.  I suspect that this is what is really causing the issues.  These dlls are not .NET assemblies, so they are still subject to the dll hell problem.  Once the main application loads the dll, there is no way to load another dll with the same name.

I'm still troubleshooting.  I'll keep you informed if I make any progress.
0 Kudos
AnthonyGrescavage
New Contributor III
Solved!

It turns out it WAS a dll issue.  It doesn't matter where you put your GDAL dlls, because ArcGIS Explorer uses GDAL, so it is pre-loaded.  This is why you are seeing the issue.  It seems like it can't find the dll, but it's really a conflict where it can't load it.  The solution is to figure out which version of GDAL that the application is using, and use the same version.  Unfortunately, it is often difficult to find the .NET wrappers for varying version of GDAL.  One direction you could go is to get the source and compile it yourself.  I can tell you, this is quite the pain.  If you're interested, I can provide you with the dlls that I compiled, which match the dlls in the most recent version of ArcGIS Explorer.
0 Kudos
AnthonyGrescavage
New Contributor III
I posted some helpful information about this issue here.
0 Kudos