This is a multi-part message in MIME format.

------=_NextPart_000_00D7_01C3C634.8A06DB10
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Major problems w/ deadline tonight! :(

I've created a DLL with the SmartPhone SDK. I've created a .NET CF app =
and try to p/invoke a function in the DLL. I always get =
System.MissingMethodException.

I've copied the DLL to both my application's folder and in the \windows =
folder on the PocketPC.

Here's my DLL code (actually, this is all auto-generated by the SDK)

#ifdef MYSTUFF_EXPORTS
#define MYSTUFF_API __declspec(dllexport)
#else
#define MYSTUFF_API __declspec(dllimport)
#endif

// This is an example of an exported function.
MYSTUFF_API int fnMyStuff(void)
{
return 42;
}

Here's the .NET code:

[System.Runtime.InteropServices.DllImport("MyStuff.dll")]
public static extern int fnMyStuff();

private void DLLButton_Click(object sender, System.EventArgs e)
{
int DLLReturned =3D fnMyStuff();
MessageBox.Show(DLLReturned.ToString());
}

The fnMyStuff() line is what triggers the exception.

Any help is greatly appreciated.. and the sooner the better! :)
------=_NextPart_000_00D7_01C3C634.8A06DB10
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Major problems w/ deadline tonight! :(</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've created a DLL with the SmartPhone SDK.&nbsp; =
I've created=20
a .NET CF app and try to p/invoke a function in the DLL.&nbsp; I always =
get=20
System.MissingMethodException.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've copied the DLL to both my application's folder =
and in the=20
\windows folder on the PocketPC.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's my DLL code (actually, this is all =
auto-generated by=20
the SDK)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>#ifdef MYSTUFF_EXPORTS<BR>#define MYSTUFF_API=20
__declspec(dllexport)<BR>#else<BR>#define MYSTUFF_API=20
__declspec(dllimport)<BR>#endif</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>// This is an example of an exported =
function.<BR>MYSTUFF_API=20
int fnMyStuff(void)<BR>{<BR>&nbsp;return 42;<BR>}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's the .NET code:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
[System.Runtime.InteropServices.DllImport("MyStuff.dll")]<BR>&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;=20
public static extern int fnMyStuff();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void=20
DLLButton_Click(object sender, System.EventArgs=20
e)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR></FONT><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int =
DLLReturned =3D=20
fnMyStuff();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
MessageBox.Show(DLLReturned.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>The fnMyStuff() line is what triggers the=20
exception.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Any help is greatly appreciated.. and the sooner the =
better!=20
:)</FONT></DIV></BODY></HTML>

------=_NextPart_000_00D7_01C3C634.8A06DB10--

Re: Desparate - ASAP - P/Invoke probs by jayderk

jayderk
Fri Dec 19 12:43:14 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_005E_01C3C62D.AB2E6BC0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Pocket OS does not have the concept of current directory...

try this..

=
[System.Runtime.InteropServices.DllImport(@"\Windows\MyStuff.dll")]
public static extern int fnMyStuff();


"Programmer" <noone@nowhere.com> wrote in message =
news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl...
Major problems w/ deadline tonight! :(

I've created a DLL with the SmartPhone SDK. I've created a .NET CF =
app and try to p/invoke a function in the DLL. I always get =
System.MissingMethodException.

I've copied the DLL to both my application's folder and in the =
\windows folder on the PocketPC.

Here's my DLL code (actually, this is all auto-generated by the SDK)

#ifdef MYSTUFF_EXPORTS
#define MYSTUFF_API __declspec(dllexport)
#else
#define MYSTUFF_API __declspec(dllimport)
#endif

// This is an example of an exported function.
MYSTUFF_API int fnMyStuff(void)
{
return 42;
}

Here's the .NET code:

[System.Runtime.InteropServices.DllImport("MyStuff.dll")]
public static extern int fnMyStuff();

private void DLLButton_Click(object sender, System.EventArgs e)
{
int DLLReturned =3D fnMyStuff();
MessageBox.Show(DLLReturned.ToString());
}

The fnMyStuff() line is what triggers the exception.

Any help is greatly appreciated.. and the sooner the better! :)
------=_NextPart_000_005E_01C3C62D.AB2E6BC0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Pocket OS does not have the concept of =
current=20
directory...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>try this..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
[System.Runtime.InteropServices.DllImport(@"\Windows\MyStuff.dll")]<BR>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
public static extern int fnMyStuff();</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Programmer" &lt;<A=20
href=3D"mailto:noone@nowhere.com">noone@nowhere.com</A>&gt; wrote in =
message <A=20
=
href=3D"news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl">news:OAOm05lxDHA.2556=
@TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT size=3D2>Major problems w/ deadline tonight! =
:(</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've created a DLL with the SmartPhone SDK.&nbsp; =
I've=20
created a .NET CF app and try to p/invoke a function in the DLL.&nbsp; =
I=20
always get System.MissingMethodException.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've copied the DLL to both my application's =
folder and in=20
the \windows folder on the PocketPC.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's my DLL code (actually, this is all =
auto-generated by=20
the SDK)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>#ifdef MYSTUFF_EXPORTS<BR>#define MYSTUFF_API=20
__declspec(dllexport)<BR>#else<BR>#define MYSTUFF_API=20
__declspec(dllimport)<BR>#endif</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>// This is an example of an exported=20
function.<BR>MYSTUFF_API int fnMyStuff(void)<BR>{<BR>&nbsp;return=20
42;<BR>}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's the .NET code:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
[System.Runtime.InteropServices.DllImport("MyStuff.dll")]<BR>&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;=20
public static extern int fnMyStuff();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void=20
DLLButton_Click(object sender, System.EventArgs=20
e)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR></FONT><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int =
DLLReturned =3D=20
fnMyStuff();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
MessageBox.Show(DLLReturned.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>The fnMyStuff() line is what triggers the=20
exception.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Any help is greatly appreciated.. and the sooner =
the better!=20
:)</FONT></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_005E_01C3C62D.AB2E6BC0--


Re: Desparate - ASAP - P/Invoke probs by Programmer

Programmer
Fri Dec 19 12:48:55 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_00ED_01C3C636.D85F1730
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Still didn't work. Thanks for the quick response!

Can you think of anything else?
"jayderk" <jayderk@hotmail.com> wrote in message =
news:OolwF$lxDHA.3436@tk2msftngp13.phx.gbl...
Pocket OS does not have the concept of current directory...

try this..

=
[System.Runtime.InteropServices.DllImport(@"\Windows\MyStuff.dll")]
public static extern int fnMyStuff();


"Programmer" <noone@nowhere.com> wrote in message =
news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl...
Major problems w/ deadline tonight! :(

I've created a DLL with the SmartPhone SDK. I've created a .NET CF =
app and try to p/invoke a function in the DLL. I always get =
System.MissingMethodException.

I've copied the DLL to both my application's folder and in the =
\windows folder on the PocketPC.

Here's my DLL code (actually, this is all auto-generated by the SDK)

#ifdef MYSTUFF_EXPORTS
#define MYSTUFF_API __declspec(dllexport)
#else
#define MYSTUFF_API __declspec(dllimport)
#endif

// This is an example of an exported function.
MYSTUFF_API int fnMyStuff(void)
{
return 42;
}

Here's the .NET code:

[System.Runtime.InteropServices.DllImport("MyStuff.dll")]
public static extern int fnMyStuff();

private void DLLButton_Click(object sender, System.EventArgs =
e)
{
int DLLReturned =3D fnMyStuff();
MessageBox.Show(DLLReturned.ToString());
}

The fnMyStuff() line is what triggers the exception.

Any help is greatly appreciated.. and the sooner the better! :)
------=_NextPart_000_00ED_01C3C636.D85F1730
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Still didn't work.&nbsp; Thanks for the quick=20
response!</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Can you think of anything else?</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"jayderk" &lt;<A=20
href=3D"mailto:jayderk@hotmail.com">jayderk@hotmail.com</A>&gt; wrote =
in message=20
<A=20
=
href=3D"news:OolwF$lxDHA.3436@tk2msftngp13.phx.gbl">news:OolwF$lxDHA.3436=
@tk2msftngp13.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Pocket OS does not have the concept =
of current=20
directory...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>try this..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
[System.Runtime.InteropServices.DllImport(@"\Windows\MyStuff.dll")]<BR>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
public static extern int fnMyStuff();</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Programmer" &lt;<A=20
href=3D"mailto:noone@nowhere.com">noone@nowhere.com</A>&gt; wrote in =
message=20
<A=20
=
href=3D"news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl">news:OAOm05lxDHA.2556=
@TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT size=3D2>Major problems w/ deadline tonight! =
:(</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've created a DLL with the SmartPhone =
SDK.&nbsp; I've=20
created a .NET CF app and try to p/invoke a function in the =
DLL.&nbsp; I=20
always get System.MissingMethodException.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've copied the DLL to both my application's =
folder and in=20
the \windows folder on the PocketPC.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's my DLL code (actually, this is all =
auto-generated=20
by the SDK)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>#ifdef MYSTUFF_EXPORTS<BR>#define MYSTUFF_API=20
__declspec(dllexport)<BR>#else<BR>#define MYSTUFF_API=20
__declspec(dllimport)<BR>#endif</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>// This is an example of an exported=20
function.<BR>MYSTUFF_API int fnMyStuff(void)<BR>{<BR>&nbsp;return=20
42;<BR>}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's the .NET code:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
[System.Runtime.InteropServices.DllImport("MyStuff.dll")]<BR>&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;=20
public static extern int fnMyStuff();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void=20
DLLButton_Click(object sender, System.EventArgs=20
e)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR></FONT><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int =
DLLReturned =3D=20
fnMyStuff();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
MessageBox.Show(DLLReturned.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>The fnMyStuff() line is what triggers the=20
exception.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Any help is greatly appreciated.. and the sooner =
the=20
better! :)</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_00ED_01C3C636.D85F1730--


Re: Desparate - ASAP - P/Invoke probs by Alex

Alex
Fri Dec 19 12:56:30 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_10EC_01C3C61E.C26A22C0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Make sure your exported functions are declared with=20
extern "C"
othewrwise you will get C++ mangled names
"Programmer" <noone@nowhere.com> wrote in message =
news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl...
Major problems w/ deadline tonight! :(

I've created a DLL with the SmartPhone SDK. I've created a .NET CF =
app and try to p/invoke a function in the DLL. I always get =
System.MissingMethodException.

I've copied the DLL to both my application's folder and in the =
\windows folder on the PocketPC.

Here's my DLL code (actually, this is all auto-generated by the SDK)

#ifdef MYSTUFF_EXPORTS
#define MYSTUFF_API __declspec(dllexport)
#else
#define MYSTUFF_API __declspec(dllimport)
#endif

// This is an example of an exported function.
MYSTUFF_API int fnMyStuff(void)
{
return 42;
}

Here's the .NET code:

[System.Runtime.InteropServices.DllImport("MyStuff.dll")]
public static extern int fnMyStuff();

private void DLLButton_Click(object sender, System.EventArgs e)
{
int DLLReturned =3D fnMyStuff();
MessageBox.Show(DLLReturned.ToString());
}

The fnMyStuff() line is what triggers the exception.

Any help is greatly appreciated.. and the sooner the better! :)
------=_NextPart_000_10EC_01C3C61E.C26A22C0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Make sure your exported functions are =
declared with=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>extern "C"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>othewrwise you will get C++ mangled=20
names</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Programmer" &lt;<A=20
href=3D"mailto:noone@nowhere.com">noone@nowhere.com</A>&gt; wrote in =
message <A=20
=
href=3D"news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl">news:OAOm05lxDHA.2556=
@TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT size=3D2>Major problems w/ deadline tonight! =
:(</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've created a DLL with the SmartPhone SDK.&nbsp; =
I've=20
created a .NET CF app and try to p/invoke a function in the DLL.&nbsp; =
I=20
always get System.MissingMethodException.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've copied the DLL to both my application's =
folder and in=20
the \windows folder on the PocketPC.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's my DLL code (actually, this is all =
auto-generated by=20
the SDK)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>#ifdef MYSTUFF_EXPORTS<BR>#define MYSTUFF_API=20
__declspec(dllexport)<BR>#else<BR>#define MYSTUFF_API=20
__declspec(dllimport)<BR>#endif</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>// This is an example of an exported=20
function.<BR>MYSTUFF_API int fnMyStuff(void)<BR>{<BR>&nbsp;return=20
42;<BR>}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's the .NET code:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
[System.Runtime.InteropServices.DllImport("MyStuff.dll")]<BR>&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;=20
public static extern int fnMyStuff();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void=20
DLLButton_Click(object sender, System.EventArgs=20
e)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR></FONT><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int =
DLLReturned =3D=20
fnMyStuff();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
MessageBox.Show(DLLReturned.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>The fnMyStuff() line is what triggers the=20
exception.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Any help is greatly appreciated.. and the sooner =
the better!=20
:)</FONT></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_10EC_01C3C61E.C26A22C0--


Re: Desparate - ASAP - P/Invoke probs by Brian

Brian
Fri Dec 19 13:02:12 CST 2003

2 things that have bitten me -- and note, I'm not a C++ programmer so a lot
this is completely new to me:

1. Make sure you're compiling for the right processor ... emulator/device.
2. Put an extern "C" on the method declaration ... something like
#define MYSTUFF_API extern "C" __declspec(dllexport)

Can't be more help as I don't know C++....

Good luck,
Brian



"Programmer" <noone@nowhere.com> wrote in message
news:O3m5CDmxDHA.2456@TK2MSFTNGP12.phx.gbl...
Still didn't work. Thanks for the quick response!

Can you think of anything else?
"jayderk" <jayderk@hotmail.com> wrote in message
news:OolwF$lxDHA.3436@tk2msftngp13.phx.gbl...
Pocket OS does not have the concept of current directory...

try this..

[System.Runtime.InteropServices.DllImport(@"\Windows\MyStuff.dll")]
public static extern int fnMyStuff();


"Programmer" <noone@nowhere.com> wrote in message
news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl...
Major problems w/ deadline tonight! :(

I've created a DLL with the SmartPhone SDK. I've created a .NET CF app and
try to p/invoke a function in the DLL. I always get
System.MissingMethodException.

I've copied the DLL to both my application's folder and in the \windows
folder on the PocketPC.

Here's my DLL code (actually, this is all auto-generated by the SDK)

#ifdef MYSTUFF_EXPORTS
#define MYSTUFF_API __declspec(dllexport)
#else
#define MYSTUFF_API __declspec(dllimport)
#endif

// This is an example of an exported function.
MYSTUFF_API int fnMyStuff(void)
{
return 42;
}

Here's the .NET code:

[System.Runtime.InteropServices.DllImport("MyStuff.dll")]
public static extern int fnMyStuff();

private void DLLButton_Click(object sender, System.EventArgs e)
{
int DLLReturned = fnMyStuff();
MessageBox.Show(DLLReturned.ToString());
}

The fnMyStuff() line is what triggers the exception.

Any help is greatly appreciated.. and the sooner the better! :)



Re: Desparate - ASAP - P/Invoke probs by Chris

Chris
Fri Dec 19 13:06:26 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_012A_01C3C639.4AAEA1A0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Run dumpbin.exe on the DLL and see what it's actually exporting.

http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/dnnetc=
omp/html/netcfdumpbinpinvoke.asp

--=20
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


"Programmer" <noone@nowhere.com> wrote in message =
news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl...
Major problems w/ deadline tonight! :(

I've created a DLL with the SmartPhone SDK. I've created a .NET CF =
app and try to p/invoke a function in the DLL. I always get =
System.MissingMethodException.

I've copied the DLL to both my application's folder and in the =
\windows folder on the PocketPC.

Here's my DLL code (actually, this is all auto-generated by the SDK)

#ifdef MYSTUFF_EXPORTS
#define MYSTUFF_API __declspec(dllexport)
#else
#define MYSTUFF_API __declspec(dllimport)
#endif

// This is an example of an exported function.
MYSTUFF_API int fnMyStuff(void)
{
return 42;
}

Here's the .NET code:

[System.Runtime.InteropServices.DllImport("MyStuff.dll")]
public static extern int fnMyStuff();

private void DLLButton_Click(object sender, System.EventArgs e)
{
int DLLReturned =3D fnMyStuff();
MessageBox.Show(DLLReturned.ToString());
}

The fnMyStuff() line is what triggers the exception.

Any help is greatly appreciated.. and the sooner the better! :)
------=_NextPart_000_012A_01C3C639.4AAEA1A0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Run dumpbin.exe on the DLL and see what =
it's=20
actually exporting.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><A=20
href=3D"http://msdn.microsoft.com/library/default.asp?url=3D/library/en-u=
s/dnnetcomp/html/netcfdumpbinpinvoke.asp">http://msdn.microsoft.com/libra=
ry/default.asp?url=3D/library/en-us/dnnetcomp/html/netcfdumpbinpinvoke.as=
p</A></FONT></DIV>
<DIV><BR>-- <BR>Chris Tacke, eMVP<BR>Co-Founder and Advisory Board =
Member<BR><A=20
href=3D"http://www.OpenNETCF.org">www.OpenNETCF.org</A><BR>---<BR>Windows=
CE=20
Product Manager<BR>Applied Data Systems<BR><A=20
href=3D"http://www.applieddata.net">www.applieddata.net</A></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Programmer" &lt;<A=20
href=3D"mailto:noone@nowhere.com">noone@nowhere.com</A>&gt; wrote in =
message <A=20
=
href=3D"news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl">news:OAOm05lxDHA.2556=
@TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT size=3D2>Major problems w/ deadline tonight! =
:(</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've created a DLL with the SmartPhone SDK.&nbsp; =
I've=20
created a .NET CF app and try to p/invoke a function in the DLL.&nbsp; =
I=20
always get System.MissingMethodException.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've copied the DLL to both my application's =
folder and in=20
the \windows folder on the PocketPC.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's my DLL code (actually, this is all =
auto-generated by=20
the SDK)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>#ifdef MYSTUFF_EXPORTS<BR>#define MYSTUFF_API=20
__declspec(dllexport)<BR>#else<BR>#define MYSTUFF_API=20
__declspec(dllimport)<BR>#endif</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>// This is an example of an exported=20
function.<BR>MYSTUFF_API int fnMyStuff(void)<BR>{<BR>&nbsp;return=20
42;<BR>}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's the .NET code:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
[System.Runtime.InteropServices.DllImport("MyStuff.dll")]<BR>&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;=20
public static extern int fnMyStuff();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void=20
DLLButton_Click(object sender, System.EventArgs=20
e)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR></FONT><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int =
DLLReturned =3D=20
fnMyStuff();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
MessageBox.Show(DLLReturned.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>The fnMyStuff() line is what triggers the=20
exception.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Any help is greatly appreciated.. and the sooner =
the better!=20
:)</FONT></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_012A_01C3C639.4AAEA1A0--


Re: Desparate - ASAP - P/Invoke probs by jayderk

jayderk
Fri Dec 19 13:14:21 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_0094_01C3C632.03CFCB80
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

I wasn't even thinking about the problem being on the dll sid... look at =
this
#ifdef DLL_IMPORT_EXPORT
#undef DLL_IMPORT_EXPORT
#endif

#ifdef DLL_SOURCE_CODE
#define DLL_IMPORT_EXPORT __declspec(dllexport) __stdcall
#else
#define DLL_IMPORT_EXPORT __declspec(dllimport) __stdcall
#endif

#ifdef __cplusplus
#define NoMangle extern "C"
#else
#define NoMangle
#endif

#undef MY_API
#ifdef MY_API_EXPORTS
#define MY_API __declspec(dllexport)
#else
#define MY_API __declspec(dllimport)
#endif
///////////////////////
NoMangle __declspec (dllexport) long __stdcall keyfobGetData();



"Programmer" <noone@nowhere.com> wrote in message =
news:O3m5CDmxDHA.2456@TK2MSFTNGP12.phx.gbl...
Still didn't work. Thanks for the quick response!

Can you think of anything else?
"jayderk" <jayderk@hotmail.com> wrote in message =
news:OolwF$lxDHA.3436@tk2msftngp13.phx.gbl...
Pocket OS does not have the concept of current directory...

try this..

=
[System.Runtime.InteropServices.DllImport(@"\Windows\MyStuff.dll")]
public static extern int fnMyStuff();


"Programmer" <noone@nowhere.com> wrote in message =
news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl...
Major problems w/ deadline tonight! :(

I've created a DLL with the SmartPhone SDK. I've created a .NET =
CF app and try to p/invoke a function in the DLL. I always get =
System.MissingMethodException.

I've copied the DLL to both my application's folder and in the =
\windows folder on the PocketPC.

Here's my DLL code (actually, this is all auto-generated by the =
SDK)

#ifdef MYSTUFF_EXPORTS
#define MYSTUFF_API __declspec(dllexport)
#else
#define MYSTUFF_API __declspec(dllimport)
#endif

// This is an example of an exported function.
MYSTUFF_API int fnMyStuff(void)
{
return 42;
}

Here's the .NET code:

[System.Runtime.InteropServices.DllImport("MyStuff.dll")]
public static extern int fnMyStuff();

private void DLLButton_Click(object sender, System.EventArgs =
e)
{
int DLLReturned =3D fnMyStuff();
MessageBox.Show(DLLReturned.ToString());
}

The fnMyStuff() line is what triggers the exception.

Any help is greatly appreciated.. and the sooner the better! :)
------=_NextPart_000_0094_01C3C632.03CFCB80
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I wasn't even thinking about the =
problem being on=20
the dll sid... look at this</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>#ifdef =
DLL_IMPORT_EXPORT<BR>&nbsp;&nbsp;&nbsp;=20
#undef DLL_IMPORT_EXPORT<BR>#endif</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#ifdef =
DLL_SOURCE_CODE<BR>&nbsp;&nbsp;&nbsp;=20
#define DLL_IMPORT_EXPORT __declspec(dllexport)=20
__stdcall<BR>#else<BR>&nbsp;&nbsp;&nbsp; #define DLL_IMPORT_EXPORT=20
__declspec(dllimport) __stdcall<BR>#endif</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#ifdef =
__cplusplus<BR>&nbsp;&nbsp;&nbsp; #define=20
NoMangle extern "C"<BR>#else<BR>&nbsp;&nbsp;&nbsp; #define=20
NoMangle<BR>#endif</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#undef MY_API<BR>#ifdef =
MY_API_EXPORTS<BR>#define=20
MY_API __declspec(dllexport)<BR>#else<BR>#define MY_API=20
__declspec(dllimport)<BR>#endif</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>///////////////////////</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>NoMangle __declspec (dllexport) long =
__stdcall=20
keyfobGetData();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Programmer" &lt;<A=20
href=3D"mailto:noone@nowhere.com">noone@nowhere.com</A>&gt; wrote in =
message <A=20
=
href=3D"news:O3m5CDmxDHA.2456@TK2MSFTNGP12.phx.gbl">news:O3m5CDmxDHA.2456=
@TK2MSFTNGP12.phx.gbl</A>...</DIV>
<DIV><FONT size=3D2>Still didn't work.&nbsp; Thanks for the quick=20
response!</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Can you think of anything else?</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"jayderk" &lt;<A=20
href=3D"mailto:jayderk@hotmail.com">jayderk@hotmail.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:OolwF$lxDHA.3436@tk2msftngp13.phx.gbl">news:OolwF$lxDHA.3436=
@tk2msftngp13.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Pocket OS does not have the concept =
of current=20
directory...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>try this..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
[System.Runtime.InteropServices.DllImport(@"\Windows\MyStuff.dll")]<BR>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
public static extern int fnMyStuff();</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Programmer" &lt;<A=20
href=3D"mailto:noone@nowhere.com">noone@nowhere.com</A>&gt; wrote =
in message=20
<A=20
=
href=3D"news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl">news:OAOm05lxDHA.2556=
@TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT size=3D2>Major problems w/ deadline tonight! =
:(</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've created a DLL with the SmartPhone =
SDK.&nbsp; I've=20
created a .NET CF app and try to p/invoke a function in the =
DLL.&nbsp; I=20
always get System.MissingMethodException.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've copied the DLL to both my application's =
folder and=20
in the \windows folder on the PocketPC.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's my DLL code (actually, this is all =
auto-generated=20
by the SDK)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>#ifdef MYSTUFF_EXPORTS<BR>#define MYSTUFF_API=20
__declspec(dllexport)<BR>#else<BR>#define MYSTUFF_API=20
__declspec(dllimport)<BR>#endif</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>// This is an example of an exported=20
function.<BR>MYSTUFF_API int fnMyStuff(void)<BR>{<BR>&nbsp;return=20
42;<BR>}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's the .NET code:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
[System.Runtime.InteropServices.DllImport("MyStuff.dll")]<BR>&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;=20
public static extern int fnMyStuff();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void=20
DLLButton_Click(object sender, System.EventArgs=20
e)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR></FONT><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int =
DLLReturned =3D=20
fnMyStuff();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
MessageBox.Show(DLLReturned.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>The fnMyStuff() line is what triggers the=20
exception.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Any help is greatly appreciated.. and the =
sooner the=20
better! =
:)</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0094_01C3C632.03CFCB80--


Re: Desparate - ASAP - P/Invoke probs by Programmer

Programmer
Fri Dec 19 14:20:35 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_0122_01C3C643.A64ABC10
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Still no go:

Here's the latest C code I have:

extern "C" __declspec (dllexport) int __stdcall PlainFunction()
{
return 123;
}

Here's the latest .NET CF code:

[System.Runtime.InteropServices.DllImport(@"\Program =
Files\PcketMeds\MyStuff.dll")]
public static extern int PlainFunction();

private void DLLButton_Click(object sender, System.EventArgs e)
{
int DLLReturned =3D PlainFunction();
MessageBox.Show(DLLReturned.ToString());
}

I also tried 2 other variations on .NET types for the function return =
type: I tried System.Int16 and System.Int32 (on both the "public =
static..." line and on the "int DLLReturned..." line.)

I'm still stuck! :(

Does anybody have a working example of an embedded VC++ 3.0 DLL and a =
.NET CF app that successfully calls it?

Thanks,
Desperate!
"jayderk" <jayderk@hotmail.com> wrote in message =
news:O5jgeQmxDHA.1196@TK2MSFTNGP12.phx.gbl...
I wasn't even thinking about the problem being on the dll sid... look =
at this
#ifdef DLL_IMPORT_EXPORT
#undef DLL_IMPORT_EXPORT
#endif

#ifdef DLL_SOURCE_CODE
#define DLL_IMPORT_EXPORT __declspec(dllexport) __stdcall
#else
#define DLL_IMPORT_EXPORT __declspec(dllimport) __stdcall
#endif

#ifdef __cplusplus
#define NoMangle extern "C"
#else
#define NoMangle
#endif

#undef MY_API
#ifdef MY_API_EXPORTS
#define MY_API __declspec(dllexport)
#else
#define MY_API __declspec(dllimport)
#endif
///////////////////////
NoMangle __declspec (dllexport) long __stdcall keyfobGetData();



"Programmer" <noone@nowhere.com> wrote in message =
news:O3m5CDmxDHA.2456@TK2MSFTNGP12.phx.gbl...
Still didn't work. Thanks for the quick response!

Can you think of anything else?
"jayderk" <jayderk@hotmail.com> wrote in message =
news:OolwF$lxDHA.3436@tk2msftngp13.phx.gbl...
Pocket OS does not have the concept of current directory...

try this..

=
[System.Runtime.InteropServices.DllImport(@"\Windows\MyStuff.dll")]
public static extern int fnMyStuff();


"Programmer" <noone@nowhere.com> wrote in message =
news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl...
Major problems w/ deadline tonight! :(

I've created a DLL with the SmartPhone SDK. I've created a .NET =
CF app and try to p/invoke a function in the DLL. I always get =
System.MissingMethodException.

I've copied the DLL to both my application's folder and in the =
\windows folder on the PocketPC.

Here's my DLL code (actually, this is all auto-generated by the =
SDK)

#ifdef MYSTUFF_EXPORTS
#define MYSTUFF_API __declspec(dllexport)
#else
#define MYSTUFF_API __declspec(dllimport)
#endif

// This is an example of an exported function.
MYSTUFF_API int fnMyStuff(void)
{
return 42;
}

Here's the .NET code:

[System.Runtime.InteropServices.DllImport("MyStuff.dll")]
public static extern int fnMyStuff();

private void DLLButton_Click(object sender, =
System.EventArgs e)
{
int DLLReturned =3D fnMyStuff();
MessageBox.Show(DLLReturned.ToString());
}

The fnMyStuff() line is what triggers the exception.

Any help is greatly appreciated.. and the sooner the better! :)
------=_NextPart_000_0122_01C3C643.A64ABC10
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Still no go:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's the latest C code I have:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>extern "C" __declspec (dllexport) int __stdcall=20
PlainFunction()<BR>{<BR>&nbsp;return 123;<BR>}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's the latest .NET CF code:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
[System.Runtime.InteropServices.DllImport(@"\Program=20
Files\PcketMeds\MyStuff.dll")]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public =
static=20
extern int PlainFunction();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void=20
DLLButton_Click(object sender, System.EventArgs=20
e)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR></FONT><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int =
DLLReturned =3D=20
PlainFunction();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
MessageBox.Show(DLLReturned.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I also tried 2 other variations on .NET types for =
the function=20
return type:&nbsp; I tried System.Int16 and System.Int32 (on both the =
"public=20
static..." line and on the "int DLLReturned..." line.)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I'm still stuck! :(</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Does anybody have a working example of an embedded =
VC++ 3.0=20
DLL and a .NET CF app that successfully calls it?</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Thanks,</FONT></DIV>
<DIV><FONT size=3D2>Desperate!</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"jayderk" &lt;<A=20
href=3D"mailto:jayderk@hotmail.com">jayderk@hotmail.com</A>&gt; wrote =
in message=20
<A=20
=
href=3D"news:O5jgeQmxDHA.1196@TK2MSFTNGP12.phx.gbl">news:O5jgeQmxDHA.1196=
@TK2MSFTNGP12.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>I wasn't even thinking about the =
problem being on=20
the dll sid... look at this</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>#ifdef =
DLL_IMPORT_EXPORT<BR>&nbsp;&nbsp;&nbsp;=20
#undef DLL_IMPORT_EXPORT<BR>#endif</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#ifdef =
DLL_SOURCE_CODE<BR>&nbsp;&nbsp;&nbsp;=20
#define DLL_IMPORT_EXPORT __declspec(dllexport)=20
__stdcall<BR>#else<BR>&nbsp;&nbsp;&nbsp; #define DLL_IMPORT_EXPORT=20
__declspec(dllimport) __stdcall<BR>#endif</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#ifdef =
__cplusplus<BR>&nbsp;&nbsp;&nbsp; #define=20
NoMangle extern "C"<BR>#else<BR>&nbsp;&nbsp;&nbsp; #define=20
NoMangle<BR>#endif</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#undef MY_API<BR>#ifdef =
MY_API_EXPORTS<BR>#define=20
MY_API __declspec(dllexport)<BR>#else<BR>#define MY_API=20
__declspec(dllimport)<BR>#endif</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>///////////////////////</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>NoMangle __declspec (dllexport) long =
__stdcall=20
keyfobGetData();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Programmer" &lt;<A=20
href=3D"mailto:noone@nowhere.com">noone@nowhere.com</A>&gt; wrote in =
message=20
<A=20
=
href=3D"news:O3m5CDmxDHA.2456@TK2MSFTNGP12.phx.gbl">news:O3m5CDmxDHA.2456=
@TK2MSFTNGP12.phx.gbl</A>...</DIV>
<DIV><FONT size=3D2>Still didn't work.&nbsp; Thanks for the quick=20
response!</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Can you think of anything else?</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"jayderk" &lt;<A=20
href=3D"mailto:jayderk@hotmail.com">jayderk@hotmail.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:OolwF$lxDHA.3436@tk2msftngp13.phx.gbl">news:OolwF$lxDHA.3436=
@tk2msftngp13.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Pocket OS does not have the =
concept of=20
current directory...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>try this..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
[System.Runtime.InteropServices.DllImport(@"\Windows\MyStuff.dll")]<BR>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
public static extern int fnMyStuff();</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Programmer" &lt;<A=20
href=3D"mailto:noone@nowhere.com">noone@nowhere.com</A>&gt; =
wrote in=20
message <A=20
=
href=3D"news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl">news:OAOm05lxDHA.2556=
@TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT size=3D2>Major problems w/ deadline tonight! =
:(</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've created a DLL with the SmartPhone =
SDK.&nbsp; I've=20
created a .NET CF app and try to p/invoke a function in the =
DLL.&nbsp; I=20
always get System.MissingMethodException.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've copied the DLL to both my application's =
folder=20
and in the \windows folder on the PocketPC.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's my DLL code (actually, this is all=20
auto-generated by the SDK)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>#ifdef MYSTUFF_EXPORTS<BR>#define =
MYSTUFF_API=20
__declspec(dllexport)<BR>#else<BR>#define MYSTUFF_API=20
__declspec(dllimport)<BR>#endif</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>// This is an example of an exported=20
function.<BR>MYSTUFF_API int =
fnMyStuff(void)<BR>{<BR>&nbsp;return=20
42;<BR>}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's the .NET code:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
[System.Runtime.InteropServices.DllImport("MyStuff.dll")]<BR>&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;=20
public static extern int fnMyStuff();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void=20
DLLButton_Click(object sender, System.EventArgs=20
e)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR></FONT><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int =
DLLReturned=20
=3D =
fnMyStuff();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
MessageBox.Show(DLLReturned.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>The fnMyStuff() line is what triggers the=20
exception.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Any help is greatly appreciated.. and the =
sooner the=20
better!=20
:)</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY=
></HTML>

------=_NextPart_000_0122_01C3C643.A64ABC10--


Re: Desparate - ASAP - P/Invoke probs by Programmer

Programmer
Fri Dec 19 14:21:37 CST 2003

Thanks. I hadn't had the extern "C". I tried that and still no go :(

Oh! And I'm compiling for the ARM processor.

"Brian" <brian-no-spam@lonewolf.tierranet.com> wrote in message
news:OFjUeKmxDHA.2440@TK2MSFTNGP12.phx.gbl...
> 2 things that have bitten me -- and note, I'm not a C++ programmer so a
lot
> this is completely new to me:
>
> 1. Make sure you're compiling for the right processor ...
emulator/device.
> 2. Put an extern "C" on the method declaration ... something like
> #define MYSTUFF_API extern "C" __declspec(dllexport)
>
> Can't be more help as I don't know C++....
>
> Good luck,
> Brian
>
>
>
> "Programmer" <noone@nowhere.com> wrote in message
> news:O3m5CDmxDHA.2456@TK2MSFTNGP12.phx.gbl...
> Still didn't work. Thanks for the quick response!
>
> Can you think of anything else?
> "jayderk" <jayderk@hotmail.com> wrote in message
> news:OolwF$lxDHA.3436@tk2msftngp13.phx.gbl...
> Pocket OS does not have the concept of current directory...
>
> try this..
>
> [System.Runtime.InteropServices.DllImport(@"\Windows\MyStuff.dll")]
> public static extern int fnMyStuff();
>
>
> "Programmer" <noone@nowhere.com> wrote in message
> news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl...
> Major problems w/ deadline tonight! :(
>
> I've created a DLL with the SmartPhone SDK. I've created a .NET CF app
and
> try to p/invoke a function in the DLL. I always get
> System.MissingMethodException.
>
> I've copied the DLL to both my application's folder and in the \windows
> folder on the PocketPC.
>
> Here's my DLL code (actually, this is all auto-generated by the SDK)
>
> #ifdef MYSTUFF_EXPORTS
> #define MYSTUFF_API __declspec(dllexport)
> #else
> #define MYSTUFF_API __declspec(dllimport)
> #endif
>
> // This is an example of an exported function.
> MYSTUFF_API int fnMyStuff(void)
> {
> return 42;
> }
>
> Here's the .NET code:
>
> [System.Runtime.InteropServices.DllImport("MyStuff.dll")]
> public static extern int fnMyStuff();
>
> private void DLLButton_Click(object sender, System.EventArgs e)
> {
> int DLLReturned = fnMyStuff();
> MessageBox.Show(DLLReturned.ToString());
> }
>
> The fnMyStuff() line is what triggers the exception.
>
> Any help is greatly appreciated.. and the sooner the better! :)
>
>



Re: Desparate - ASAP - P/Invoke probs by Paul

Paul
Fri Dec 19 14:42:09 CST 2003

I always just put my DLLs in a good location, like the \Windows directory.
Maybe you should put it there and remove the path from your DllImport
entirely. You don't need the __stdcall attribute on your function, either.
You might also use the depends.exe viewer on your DLL to make sure that the
function name is what you're expecting. Depends.exe comes with eVC.

Paul T.

"Programmer" <noone@nowhere.com> wrote in message
news:eAH8Q2mxDHA.2304@TK2MSFTNGP12.phx.gbl...
Still no go:

Here's the latest C code I have:

extern "C" __declspec (dllexport) int __stdcall PlainFunction()
{
return 123;
}

Here's the latest .NET CF code:

[System.Runtime.InteropServices.DllImport(@"\Program
Files\PcketMeds\MyStuff.dll")]
public static extern int PlainFunction();

private void DLLButton_Click(object sender, System.EventArgs e)
{
int DLLReturned = PlainFunction();
MessageBox.Show(DLLReturned.ToString());
}

I also tried 2 other variations on .NET types for the function return type:
I tried System.Int16 and System.Int32 (on both the "public static..." line
and on the "int DLLReturned..." line.)

I'm still stuck! :(

Does anybody have a working example of an embedded VC++ 3.0 DLL and a .NET
CF app that successfully calls it?

Thanks,
Desperate!
"jayderk" <jayderk@hotmail.com> wrote in message
news:O5jgeQmxDHA.1196@TK2MSFTNGP12.phx.gbl...
I wasn't even thinking about the problem being on the dll sid... look at
this
#ifdef DLL_IMPORT_EXPORT
#undef DLL_IMPORT_EXPORT
#endif

#ifdef DLL_SOURCE_CODE
#define DLL_IMPORT_EXPORT __declspec(dllexport) __stdcall
#else
#define DLL_IMPORT_EXPORT __declspec(dllimport) __stdcall
#endif

#ifdef __cplusplus
#define NoMangle extern "C"
#else
#define NoMangle
#endif

#undef MY_API
#ifdef MY_API_EXPORTS
#define MY_API __declspec(dllexport)
#else
#define MY_API __declspec(dllimport)
#endif
///////////////////////
NoMangle __declspec (dllexport) long __stdcall keyfobGetData();



"Programmer" <noone@nowhere.com> wrote in message
news:O3m5CDmxDHA.2456@TK2MSFTNGP12.phx.gbl...
Still didn't work. Thanks for the quick response!

Can you think of anything else?
"jayderk" <jayderk@hotmail.com> wrote in message
news:OolwF$lxDHA.3436@tk2msftngp13.phx.gbl...
Pocket OS does not have the concept of current directory...

try this..


[System.Runtime.InteropServices.DllImport(@"\Windows\MyStuff.dll")]
public static extern int fnMyStuff();


"Programmer" <noone@nowhere.com> wrote in message
news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl...
Major problems w/ deadline tonight! :(

I've created a DLL with the SmartPhone SDK. I've created a .NET CF
app and try to p/invoke a function in the DLL. I always get
System.MissingMethodException.

I've copied the DLL to both my application's folder and in the
\windows folder on the PocketPC.

Here's my DLL code (actually, this is all auto-generated by the SDK)

#ifdef MYSTUFF_EXPORTS
#define MYSTUFF_API __declspec(dllexport)
#else
#define MYSTUFF_API __declspec(dllimport)
#endif

// This is an example of an exported function.
MYSTUFF_API int fnMyStuff(void)
{
return 42;
}

Here's the .NET code:

[System.Runtime.InteropServices.DllImport("MyStuff.dll")]
public static extern int fnMyStuff();

private void DLLButton_Click(object sender, System.EventArgs
e)
{
int DLLReturned = fnMyStuff();
MessageBox.Show(DLLReturned.ToString());
}

The fnMyStuff() line is what triggers the exception.

Any help is greatly appreciated.. and the sooner the better! :)



Re: Desparate - ASAP - P/Invoke probs by Programmer

Programmer
Fri Dec 19 14:47:08 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_013E_01C3C647.5BCCC530
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Thanks. Did that... still no go :(
"Alex Feinman [MVP]" <public_news@alexfeinman.com> wrote in message =
news:%23BTpRHmxDHA.2556@TK2MSFTNGP10.phx.gbl...
Make sure your exported functions are declared with=20
extern "C"
othewrwise you will get C++ mangled names
"Programmer" <noone@nowhere.com> wrote in message =
news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl...
Major problems w/ deadline tonight! :(

I've created a DLL with the SmartPhone SDK. I've created a .NET CF =
app and try to p/invoke a function in the DLL. I always get =
System.MissingMethodException.

I've copied the DLL to both my application's folder and in the =
\windows folder on the PocketPC.

Here's my DLL code (actually, this is all auto-generated by the SDK)

#ifdef MYSTUFF_EXPORTS
#define MYSTUFF_API __declspec(dllexport)
#else
#define MYSTUFF_API __declspec(dllimport)
#endif

// This is an example of an exported function.
MYSTUFF_API int fnMyStuff(void)
{
return 42;
}

Here's the .NET code:

[System.Runtime.InteropServices.DllImport("MyStuff.dll")]
public static extern int fnMyStuff();

private void DLLButton_Click(object sender, System.EventArgs =
e)
{
int DLLReturned =3D fnMyStuff();
MessageBox.Show(DLLReturned.ToString());
}

The fnMyStuff() line is what triggers the exception.

Any help is greatly appreciated.. and the sooner the better! :)
------=_NextPart_000_013E_01C3C647.5BCCC530
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Thanks.&nbsp; Did that... still no go =
:(</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Alex Feinman [MVP]" &lt;<A=20
=
href=3D"mailto:public_news@alexfeinman.com">public_news@alexfeinman.com</=
A>&gt;=20
wrote in message <A=20
=
href=3D"news:%23BTpRHmxDHA.2556@TK2MSFTNGP10.phx.gbl">news:%23BTpRHmxDHA.=
2556@TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>Make sure your exported functions are =
declared=20
with </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>extern "C"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>othewrwise you will get C++ mangled=20
names</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Programmer" &lt;<A=20
href=3D"mailto:noone@nowhere.com">noone@nowhere.com</A>&gt; wrote in =
message=20
<A=20
=
href=3D"news:OAOm05lxDHA.2556@TK2MSFTNGP10.phx.gbl">news:OAOm05lxDHA.2556=
@TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT size=3D2>Major problems w/ deadline tonight! =
:(</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've created a DLL with the SmartPhone =
SDK.&nbsp; I've=20
created a .NET CF app and try to p/invoke a function in the =
DLL.&nbsp; I=20
always get System.MissingMethodException.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I've copied the DLL to both my application's =
folder and in=20
the \windows folder on the PocketPC.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's my DLL code (actually, this is all =
auto-generated=20
by the SDK)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>#ifdef MYSTUFF_EXPORTS<BR>#define MYSTUFF_API=20
__declspec(dllexport)<BR>#else<BR>#define MYSTUFF_API=20
__declspec(dllimport)<BR>#endif</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>// This is an example of an exported=20
function.<BR>MYSTUFF_API int fnMyStuff(void)<BR>{<BR>&nbsp;return=20
42;<BR>}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here's the .NET code:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
[System.Runtime.InteropServices.DllImport("MyStuff.dll")]<BR>&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;=20
public static extern int fnMyStuff();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void=20
DLLButton_Click(object sender, System.EventArgs=20
e)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR></FONT><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int =
DLLReturned =3D=20
fnMyStuff();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
=
MessageBox.Show(DLLReturned.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>The fnMyStuff() line is what triggers the=20
exception.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Any help is greatly appreciated.. and the sooner =
the=20
better! :)</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_013E_01C3C647.5BCCC530--


Re: Desparate - ASAP - P/Invoke probs by Programmer

Programmer
Fri Dec 19 14:50:37 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_014A_01C3C647.D8615160
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

"PlainFunction" is now the function I'm testing with... It's declared =
like this:

extern "C" __declspec (dllexport) int __stdcall PlainFunction()
{
return 123;
}

and in .NET, I use it like this: