[Shapelib] Shapelib.dll PInvoke error

Constanze Tschritter Conny3 at gmx.de
Mon Feb 26 13:02:24 EST 2007


Dear List,

When I tried to compile my Pocket PC 2003 project, the result was a MissingMethodException saying the entry point SHPopen within the PInvoke DLL shapelib.dll was not found (I’ve got the german version of Visual studio 8, but this is more or less what it said). 

Here is the offending code snippet:

Const STRSHAPEPATH As String = "xxx\\xxx\\strassen.shp"

Private Sub ReadArcShape()
        Dim myShapeType As ShapeLib.ShapeType = ShapeLib.ShapeType.PolyLine
        Dim hShape As IntPtr = New IntPtr()
        Dim intNum As Integer = 0
        Dim dblMinBounds As Double() = New Double(1) {0, 0}
        Dim dblMaxBounds As Double() = New Double(1) {0, 0}

'At this point I get the MissingMethodException
hShape = ShapeLib.SHPOpen(STRSHAPEPATH, "rb")
…
End Sub

Looking up that error message at the internet I found some possible causes for the error but until now, nothing I tried changed anything: 

 1) Platform:  I downloaded the Shapelib .Net Wrapper by David Gancarz and recompiled the shapelib for Pocket-PC 2003. However I got an error message, when I tried to use the same shapelib files he did. Thus I used a windows ce shapelib package which had been assembled by Mateusz Loskot and was able to compile those without problems. The only difference I noticed was, that this package contained more files than David Gancarz had used. 

A test with

“Dumpbin /header shapefile.dll |find “machine”” resulted in 
	
	“1C0 machine(ARM)” so I must have done something right. 

Afterwards I tried to recompile the Maptools-Project (which is said wrapper project), now with the new shapelib.dll. The only error message I got was that the post build event copy $(ProjectDir)shapelib.dll  $(TargetDir) had failed, so I copied it manually into my project folder. I’m not sure if that was the right thing to do, because I don’t know the background behind this.

I added the maptools.dll reference to my project, but got an error, when I tried the same with the shapelib (“Unable to add reference to Shapelib.dll”). Do I even have to add that, too, or is sufficient to only add the maptools.dll? Well everything seemed to be ok, though, Visual studio recognized the Shapelib functions. 

 2) Build Action: I set the build action of the shapelib.dll in my project to content, but nothing changed.

 3) PInvoke: I thought with the .Net wrapper I won’t have to worry about PInvoke.(?)

I don’t know what else to do. I must have missed something, but I don’t know what. Maybe someone here can give me a hint what I’m doing wrong. Thank you very much in advance!

Cheers
Constanze Tschritter

PS: Sorry for the long mail. I didn't know how to describe it in a shorter way.


-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer


More information about the Shapelib mailing list