[C#][VS 2005 Bete 2] creating & using a C++ in a C# project

Hi,
I try to create a unmanaged dll in C++ with visualt studio 2005 and the i want to use it in a c# project.
My first question is hoaw to create a C++ (unmanaged) dll project for smartphone in visual stuido 2005. I create a Win32 projecdt>>dll project but i supopose it's only for deskop.

After that i wrote my dll.
.CPP

#include "MyDll.h"
// This is an example of an exported function.
MYDLL_API int fnMyDll()
{
return 42;}

.H

#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif
MYDLL_API int fnMyDll();

Then i use it in my C# project

[DllImport("MyDll.dll",EntryPoint="fnMyDll",CharSet=CharSet.Unicode)]

private static extern int fnMyDll();

int GetInt()

{

return fnMyDll();

}

-----------------

But at run time i get a Missing Methode Exception.
For running my app i direclty dowload the dll in the exe folder, so the exe should find the methode :s

So does anyone knows how to make such a thing (creat a C++ dll project for smartphoen and then use it i a C# project) with visual 2005



Answer this question

[C#][VS 2005 Bete 2] creating & using a C++ in a C# project

  • interscape

    You have to create a VC++ for SmartDevices project to build this DLL. You can create the project within the same solution as your other project, for convenience. Of course, you have to have VC++ installed for this option to be available.

    - Larry

  • Peregrine Falcon

    here it is

    extern "C"
    {
    MYDLL_API int fnMyDll();
    }

    .NET does not supportname mangling :(
    To bad..

  • Catalin Enescu

    Perfect that's it.
    Really thanks ;o)

  • marvic

    Ok it's working for a smart device dll using MFC, but if a remember well, MFC are not supported under Windows Mobiel 2003 SE !!

    So how can i create a simple C++ dll, for the moment i cretae my C++ dll in embedded VC ++ and upload the dll on my real smartphone. The tests are not possible since code for embedded VC++ emulator and Visual Stuidio 2005 emulator are not compatible.

    So my question is still the same, how to create a basic C++ dll for smartphone from Visual Stuidio 2005

    Thanks

  • Islandwind

    Yeah thanks for that ;)
    And waht about creating simple c++ dll for smartphone in visual studio 2005
    I can't make it :)

  • N B

    ..or you could use dumpbin to declare the name exactly as it is exported. More here:
    http://msdn.microsoft.com/smartclient/understanding/netcf/FAQ/default.aspx#6.0

    Cheers
    Daniel



  • jbarton

    Select the "Other Language/Visual C++/Smartdevice" and then template "Win32 Smart Device Project" in the New Project dialog. This presents a wizard that has a selection "Application Settings". It is there you can select "DLL" as the project type.

    Dale


  • [C#][VS 2005 Bete 2] creating & using a C++ in a C# project