I'm trying to call my C++/CLI dll from a C# library. I gives me the error
unable to find an entry point named GetA
Here's my C++/CLI file:
#pragma once
//#ifdef WRAPPERAPI_EXPORTS
//#define WRAPPER_API extern "C" __declspec(dllexport)
//#else
//#define WRAPPER_API extern "C" __declspec(dllimport)
//#endif
#include "windows.h"
#include "Common.h"
namespace Wrapper
{
int GetA();
int GetB();
void Preinitialize();
}
As you can see I have also tried with a module definition file, but it
didn't work (perhaps it is not supposed to work with C++/CLI libraries?).
In dependency walker there seem to be no functions listed. I'm not sure if
it should show with a C++/CLI module...?
I know I had this project working before... :(
Hi Joachim,
> I'm trying to call my C++/CLI dll from a C# library. I gives me the
> error unable to find an entry point named GetA
[quoted text clipped - 18 lines]
> void Preinitialize();
> }
I am not sure if a namespace mangles the names? I woudl expect that it does.
So move the exported functions into the global namespace and use your
WRAPPER_API define:
WRAPPER_API int GetA();
WRAPPER_API int GetB();
> As you can see I have also tried with a module definition file, but it
> didn't work (perhaps it is not supposed to work with C++/CLI
> libraries?).
You still need a def file to avoid name mangling
> In dependency walker there seem to be no functions listed. I'm not
> sure if it should show with a C++/CLI module...?
Please recheck in Depends after you changed the above.
--
SvenC
Josh Chang - 20 May 2007 02:30 GMT
Hi SvenC,
There is a bug in VS2005 (VC8), some dll entry point couldn't be
found....
I dont know if this is exacly the problem of yours...but it worth a try.....
[Solution of workaround]
Open the project of your VC++ dll,
Project | XXX Properties ->
Configuration Properties -> General -> Use of MFC
Change from "Use Standard Windows Libraries" to "Use MFC in a Static
Library"
and then rebuild the project for the first time, this will add some
missing components into your dll.......
finally swith back to "Use Standard Windows Libraries" and rebuild for
the 2nd time.....you ll have the final workable .dll........
Try it......hope this is helpful
> Hi Joachim,
>
[quoted text clipped - 41 lines]
> --
> SvenC
Ben Voigt - 23 May 2007 00:20 GMT
> Hi Joachim,
>
[quoted text clipped - 23 lines]
> I am not sure if a namespace mangles the names? I woudl expect that it
> does.
It does for C++ names, but not for extern "C" identifiers.
> So move the exported functions into the global namespace and use your
> WRAPPER_API define:
[quoted text clipped - 15 lines]
> --
> SvenC