Click here to Skip to main content
15,065,783 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir,
I need to implement a Win32 DLL and need call it by C# DllImport in WinCE.
So I create a Win32 Smart Device Project and choice Windows Mobile 5.0 Smartphone SDK,
and create a dll project with Export symbols option.
Then I add extern "C" key word before function declare:
#define WINCE2_API __declspec(dllexport)
#define WINCE2_API extern "C" __declspec(dllimport)
  extern "C" WINCE2_API int __cdecl Add(int A,int B);
  extern "C" WINCE2_API int __cdecl Add(int A,int B)
      return A+B;

When I use DllImport in C#:
[DllImport("WinCE2.dll", EntryPoint = "Add")]
static extern int Add(int A, int B);

I always got a System.MissingMethodException in WinCE 5.0 emulator and WinCE6.0 Device.

I searched some information on google, found some solution.
First, Add .def in project:
LIBRARY     "WinCE2"
Add         DATA 

But in CSDN forum some one say __declspec(dllexport) can replace the .def file.
But this solution also got System.MissingMethodException.

Then I found a solution on Stack Overflow:
May I need add __cdecl key word.
And I created a Win32 DLL Project, I found the project setting will add __cdecl in default.
But Win32 Smartphone project is not.
So I try it, but also got System.MissingMethodException.
Then I try the same code in Win32 DLL and call by C#, it can work.
So I don't know why wince can't work.
Can anyone share me some expeience?
Updated 29-Jul-11 4:15am
Sergey Chepurin 29-Jul-11 11:20am
It is very unlikely that you will find someone with that mixture of skills applied to WinCE here. May be you should try MSDN Forum on Windows Embedded Compact:
Cloud Hsu 29-Jul-11 11:48am
I got it, thank you very much.
Next working day, I will try another solution and ask this question in MSDN Forum.
I want to rest in this weekend, worked too tired in this week.

1 solution

I try to install WinCE Standard SDK 5.0 in my computer and create a standard sdk project.
Then I select x86 CPU to build dll, and the dll can work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900