Home > Archive > Smartphone Developer Forum > April 2006 > p/invoke
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hello,
I have a problem using p/invoke on Smartphone 2003. The strange thing is
that I tested the same application (only compiled the dll and the c# app for
Pocket PC 2003) on Pocket PC 2003 and there it works.
The dll exposes these two functions:
#ifdef WRAPPERDLL_EXPORTS
#define WRAPPERDLL_API __declspec(dllexport)
#else
#define WRAPPERDLL_API __declspec(dllimport)
#endif
extern "C" WRAPPERDLL_API DWORD SendMessageWrapper(LPCTSTR label, LPCTSTR
msg);
extern "C" WRAPPERDLL_API void Test (void);
and in the C# app I declare and call the first function like this:
[DllImport("WrapperDLL.dll",EntryPoint="#1")]
static extern int SendMessageWrapper(String lbl, String msg);
............
static public int sendMessage(String label, String message)
{
...........
try
{
ret = SendMessageWrapper(label, message);
}
catch (Exception e){}
return ret;
}
This call throws a MissingMethodException. The dll is in the same directory
as the C# application (I tried it also with the dll in \windows\).
Any idea why it behaves differently on Pocket PC and on Smartphone?
Thanks,
Lucia.
| |
|
| I guess it has to do with the Smartphone Application Security and Code
Signing Model?!?...
| |
| John Nossluap 2006-04-01, 8:02 am |
| lucia wrote:
> I guess it has to do with the Smartphone Application Security and Code
> Signing Model?!?...
Mmm, try signing both (or atleast the dll) with a test developer
certificate installed on the device and have another go.
| |
| Tom Moon 2006-04-07, 7:05 pm |
| The EntryPoint should tell the name of the function in C
from:
[DllImport("WrapperDLL.dll",EntryPoint="#1")]
to:
[DllImport("WrapperDLL.dll",EntryPoint="SendMessageWrapper")]
-J Tom Moon
| |
| Brian Nantz 2006-04-10, 8:18 am |
| There are lots of examples at pinvoke.net
lucia wrote:
> Hello,
>
> I have a problem using p/invoke on Smartphone 2003. The strange thing is
> that I tested the same application (only compiled the dll and the c# app for
> Pocket PC 2003) on Pocket PC 2003 and there it works.
>
> The dll exposes these two functions:
>
> #ifdef WRAPPERDLL_EXPORTS
> #define WRAPPERDLL_API __declspec(dllexport)
> #else
> #define WRAPPERDLL_API __declspec(dllimport)
> #endif
> extern "C" WRAPPERDLL_API DWORD SendMessageWrapper(LPCTSTR label, LPCTSTR
> msg);
> extern "C" WRAPPERDLL_API void Test (void);
>
> and in the C# app I declare and call the first function like this:
>
> [DllImport("WrapperDLL.dll",EntryPoint="#1")]
> static extern int SendMessageWrapper(String lbl, String msg);
> ...........
> static public int sendMessage(String label, String message)
> {
> ...........
> try
> {
> ret = SendMessageWrapper(label, message);
> }
> catch (Exception e){}
> return ret;
> }
>
> This call throws a MissingMethodException. The dll is in the same directory
> as the C# application (I tried it also with the dll in \windows\).
>
> Any idea why it behaves differently on Pocket PC and on Smartphone?
>
> Thanks,
> Lucia.
|
|
|
|
|