DLL

H

Hilton

Hi,

I wrote some simple DLL code, created a DLL called DLLTest.dll and copied it
to a directory on the Pocket PC:

#include "stdafx.h"
#include "DLLTest.h"


extern "C" __declspec(dllexport) int __cdecl Function1(void)
{
return 42;
}

I have tried various combination of the above; e.g. with/without __cdecl
etc.
--------------------
Then I wrote:
private void button1_Click(object sender, System.EventArgs ea)
{
MessageBox.Show (Function1().ToString());
}

[DllImport("DLLTest.dll", EntryPoint="Function1")] <--- I've
tried this without EntryPoint
static extern int Function1();

and put this EXE in the same directory. When I run the EXE, I get a
MissingMethodException, the message "Can't find PInvoke DLL 'DLLTest.dll'.
The DLL is definitely in the directory, so I'm thinking that I might need to
add/remove some linking options.

When I create the DLL project in VS2005, it setup these options for me:
/OUT:"Pocket PC 2003 (ARMV4)\Debug/DLLTest.dll" /INCREMENTAL /NOLOGO /DLL
/MANIFEST:NO /NODEFAULTLIB:"oldnames.lib" /DEF:".\DLLTest.def" /DEBUG
/PDB:"c:\stuff\dlltest\dlltest\pocket pc 2003 (armv4)\debug\DLLTest.pdb"
/STACK:65536,4096 /IMPLIB:"Pocket PC 2003 (ARMV4)\Debug/DLLTest.lib"
/ERRORREPORT:pROMPT ole32.lib oleaut32.lib uuid.lib

/subsystem:windowsce,4.20 /machine:ARM /ARMPADCODE

If you want me to stop going bald - help! :)

Hilton
 
H

Hilton

Hi,

OK, fixed. I spent hours trying to figure out why it was not finding the
function. I used dumpbin to figure out that I had a desktop DLL and various
dependencies. So the DLL was being found, just not loaded correctly - would
be nice if MS could report this better. Anyway, I used VS2005 and setup a
Pocket PC DLL and with a few other tweaks, I'm up and running.

Here's something that might help others. While I was changing a bunch of
options in VS, I also copied mspdb80.dll from its location to the bin
directory in which dumpbin.exe resides - no harm I thought - dumpbin
actually works now. Then VS started reporting a "fatal error C1902" -
everything I read on the web said reinstall VS - ha ha - very funny. I
deleted mspdb80.dll and everything was good again. What the heck? That all
just seems way too flimsy for me and the cryptic message didn't help.

Anyway, all is good, now I can actually start writing code.

Hilton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top