How to reuse standard C code in a CF c# solution ?

  • Thread starter Thread starter Sagaert Johan
  • Start date Start date
It depends what you want to do with your existing code
base. If your code exists inside a DLL you could consider
P/Invoking to native code. Keep in mind that there are
limitations to P/Invoking to native code. There are some
articles available on P/Invoke, for instance
http://msdn.microsoft.com/library/en-
us/dnnetcomp/html/netcfintrointerp.asp and
http://msdn.microsoft.com/library/en-
us/dnnetcomp/html/netcfadvinterop.asp. Could you give more
information on what is not working or how you try to reuse
your existing code?

Regards,
Maarten Struys, eMVP
PTS Software bv
 
Using code from a DLL is impossible since the target is a smartdevice

I have a lot of (ansi-C) code and just want to used it in new c# project
targeting smartdevices (CF)
 
You lost me with this comment. Why is it impossible? You can call DLL
functions from Smart Device Applications (have a look at OpenNetCF; there
are hundreds of P/Invokes in there).

If you really want to use the code as-is from your CF application, you'll
*have* to make it into a DLL.

Paul T.
 
I am a bit confused.

If i add a cpp class lib project to my pocket pc solution it shows up as
having win32 platform attribute , while other projects in the solution are
Pocket PC .
So i doubt that this will work .
Or do i need to create my dll first in eVC4 ,and the use it in my pocket pc
solution ?
 
Well yes, what you need to do is indeed create your DLL in eVC 4 (creating a
WCE Dynamic Link Library). Make sure that the functions you want to use from
within your CF application are exported as C functions (using extern "C") or
the function names inside your DLL will be mangled.
--
Regards,

Maarten Struys, eMVP
PTS Software bv
 
Back
Top