C++ DLL used in C# project

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

We developped many Dll in C++ to use in a project developped with VC++ 6.0.

Now we have another project for Pocket PC that I have to develop with C#,
can I use the same DLL, and what I have to do ?

Thanks
 
Since PPC is based on Windows CE, a fair number of the API declarations,
const values, etc. are the same as the desktop. You may need to make some
modifications to the source depending on what you're actually doing in the
dlls, however, you'll need to recompile the dlls using either eVC++ 3.0 or
eVC++ 4.0. Which version you need to use depends on the PPC version that
you're targeting. PPC 2002 and down - eVC++ 3.0, PPC 2003 and up - eVC++
4.0.

See the link below for some more information on p/invoking through the
compact framework.
http://wiki.opennetcf.org/ow.asp?CompactFrameworkFAQ/CallingNativeFunctions
 
Hermione,

You have two options.

The first is to take the C++ dll and expose the types in it through COM.
Once you do that, you can access it in .NET through COM interop.

The second way is to create managed wrappers for your types (which could
be much more difficult, depending on how your classes are laid out and how
they interact with each other). If you do that, then you would be able to
re-compile your DLL as a managed DLL and then add a reference to it from VS.

Hope this helps.
 
I should have mentioned that the official compact framework newsgroup is
located here (microsoft.public.dotnet.framework.compactframework). So if you
run into any issues then you may want to post them over there as you'll
usually get a pretty quick and accurate response.
 
Thnks Tim

But can I compile the DLL with the Visual C++ which came in the package of
VisualStudio 2003

Thanks
 
Thanks Nicolas, I'll will look at your suggestions



Nicholas Paldino said:
Hermione,

You have two options.

The first is to take the C++ dll and expose the types in it through COM.
Once you do that, you can access it in .NET through COM interop.

The second way is to create managed wrappers for your types (which could
be much more difficult, depending on how your classes are laid out and how
they interact with each other). If you do that, then you would be able to
re-compile your DLL as a managed DLL and then add a reference to it from VS.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Hermione said:
Hi,

We developped many Dll in C++ to use in a project developped with VC++
6.0.

Now we have another project for Pocket PC that I have to develop with C#,
can I use the same DLL, and what I have to do ?

Thanks
 
You cannot compile native dlls targeting Pocket PCs through VS.Net 2003. You
will need either eVC++ 3.0 or 4.0 (they're both free downloads from
Microsoft). However, you will be able to compile native code for PPCs in
Visual Studio 2005.
 
Back
Top