[Shapelib] Shapelib.dll PInvoke error

Constanze Tschritter Conny3 at gmx.de
Tue Feb 27 01:58:38 PST 2007

Hi David,

Thank you very much for your fast reply! 

Well, the thing is, that I've already compiled the shapelib files for Pocket PC 2003 and I still got that error. 

Just to be sure that I did everything right, here is everything I did in a nutshell: 

1) I first compiled the shapelib files for PPC 2003. 
2) Then I recompile the .Net Wrapper, now with the new Shapelib
3) I add a reference to the Maptools.dll and deploy the shapelib.dll either manually or automatically into my device.

I'll now have a look at the use of PInvoke in the netcf. Maybe the error lies therein.


-------- Original-Nachricht --------
Datum: Mon, 26 Feb 2007 13:31:09 -0500
Von: David.Gancarz at ci.orlando.fl.us
An: Shapelib Development <shapelib at lists.maptools.org>
Betreff: Re: [Shapelib] Shapelib.dll PInvoke error

> Conny: 
> It's been a while since I did anything with PocketPC, so I don't remember 
> all the differences between .NET on it versus full Windows.  But ... 
> regarding the shapelib.dll -- it dos not need to be included in your 
> Visual Studio project; it just needs to reside in a place the your 
> assembly can find it (typically, the same directory -- which is exactly 
> where the post build event puts it).  Copying it there manually, as you 
> did, accomplishes the same thing.  Shapelib.dll gets called at runtime. It
> does not become part of the .net assembly, so your Visual Studio solution 
> ReadArcShape needs no reference to it at all.  It only needs shapelib.dll 
> at runtime. 
> Secondly, the version of shapelib.dll on MapTools.org is compiled for 
> windows, so you will need to recompile it for Windows CE.  The C/C++ 
> source and VS projects should be out on the Shapelib site.  That should be
> possible since there is nothing exotic or windows-specific about the 
> shapelib c code. 
> Finally, I wouldn't  think you will need to revisit the PInvoke calls in 
> the .net wrapper.  As I recall the Compact Framework supports PInvoke -- 
> although you might want to check the details on that. 
> I hope some of this helps, and good luck.
> David Gancarz
> ----------------------------------------
> Florida has a very broad public records law.  As a result, any written 
> communication created or received by City of Orlando officials and 
> employees will be made available to the public and media, upon request, 
> unless otherwise exempt.  Under Florida law, email addresses are public 
> records.  If you do not want your email address released in response to a 
> public records request, do not send electronic mail to this office. 
> Instead, contact our office by phone or in writing.
> "Constanze Tschritter" <Conny3 at gmx.de> 
> Sent by: shapelib-bounces at lists.maptools.org
> 02/26/2007 01:02 PM
> Please respond to
> Shapelib Development <shapelib at lists.maptools.org>
> To
> shapelib at lists.maptools.org
> cc
> Subject
> [Shapelib] Shapelib.dll PInvoke error
> 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 fur Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
> _______________________________________________
> Shapelib mailing list
> Shapelib at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/shapelib

Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser

More information about the Shapelib mailing list