[Shapelib] I have the dll compiled but know I have to make it works in the emulator.

Mateusz Loskot mateusz at loskot.net
Thu Aug 24 18:33:20 EDT 2006

Daniel de la Cuesta wrote:
> That´s right!!! I have just compiled the shapefile.dll for 
> SmartPhones. You are very nice. Thank you.

You're welcome!

> But now I have another problem, I have added the shapefile.dll to my 
> Compact Framework project (Add Existing Item) but I cannot acces to 
> the .dll when the app is running. I get the following exception when
>  I try to access the shapefile.dll during execution:
> MissingMethodException was unhandled Can't find PInvoke DLL 
> 'shapelib.dll'

Please, confirm this checklist (though, there are more issues possible):

1. Your DLL is indeed compiled for Pocket PC and correct CPU
architecture, but not for desktop

2. You've deployed (tricky, may not work with DLL) or manually uploaded
your shapefile.dll file to the mobile device, into directory where is
your .NET CF application .exe file.

If you want to deploy DLL automatically, follow these steps:
1. Right click on your .NET CF app project in the solution explorer
2. Choose Add/Existing Item
3. Navigate to your shapefile.dll
4. Select this file in the solution explorer.
5. Change "Build Action" to "Content"

Note, that after your DLL is uploaded on the device or emulator,
File Explorer won't show it in directory listings because DLLs are
hidden by default.
So, enable "Show all files" to see it.

If you will experience problems with accessing Shapelib API
from .NET Compact Framework, please refer also to following resources:

.NET Compact Framework FAQ: Interoperability

An Introduction to P/Invoke and Marshaling on
the Microsoft .NET Compact Framework

Marshalling Types During Platform Invoke (P/Invoke) on
the Microsoft .NET Compact Framework

Advanced P/Invoke on the Microsoft .NET Compact Framework

Section "Interoperability":

Using dumpbin.exe as an Aid for Declaring P/Invokes

I hope it helps.

Mateusz Loskot

More information about the Shapelib mailing list