G
Guest
I have no trouble passing __delegate ptrs to native C functions in DLLs,
however when attempting to pass the __delegate ptr to a native C++ function
in a DLL I get the following runtime exception: An unhandled exception of
type 'System.EntryPointNotFoundException'.
This is confusing b/c if the entry point was not found, I would think I'd
get an unresolved symbol error during linking. Furthermore, I can
successfully pass void, int *, and function pointers, etc to C++ DLL
functions, but this error persists when attempting to pass a __delegate
pointer, which is used for callbacks to managed C++ functions.
Here is the relevant code snippet - the DLL code simply contains stubs of
the functions called here:
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
__delegate void testCB();
[DllImport("unmdll.dll")]
void fnunmdll_2(testCB *UpdateProgMeter);
int fnunmdll_0(void);
void fnunmdll_1(int *x);//testCB *UpdateProgMeter);
__gc class C1
{
public:
static void handleCB()
{
return;
}
};
int _tmain()
{
int k = 9;
//always works (as both C/C++)
fnunmdll_0();
//always works (as both C/C++)
fnunmdll_1(&k);
testCB *pCB = new testCB(0, &C1::handleCB);
//if this is a C++ function expecting a function pointer, the
aforementioned error occurs. If this is an extern "C" function, all is ok!
fnunmdll_2(pCB);
return 0;
}
As crazy as it sounds, I'm beginning to think this is not possible to do
with native C++ functions.
Thanks in advance, George
however when attempting to pass the __delegate ptr to a native C++ function
in a DLL I get the following runtime exception: An unhandled exception of
type 'System.EntryPointNotFoundException'.
This is confusing b/c if the entry point was not found, I would think I'd
get an unresolved symbol error during linking. Furthermore, I can
successfully pass void, int *, and function pointers, etc to C++ DLL
functions, but this error persists when attempting to pass a __delegate
pointer, which is used for callbacks to managed C++ functions.
Here is the relevant code snippet - the DLL code simply contains stubs of
the functions called here:
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
__delegate void testCB();
[DllImport("unmdll.dll")]
void fnunmdll_2(testCB *UpdateProgMeter);
int fnunmdll_0(void);
void fnunmdll_1(int *x);//testCB *UpdateProgMeter);
__gc class C1
{
public:
static void handleCB()
{
return;
}
};
int _tmain()
{
int k = 9;
//always works (as both C/C++)
fnunmdll_0();
//always works (as both C/C++)
fnunmdll_1(&k);
testCB *pCB = new testCB(0, &C1::handleCB);
//if this is a C++ function expecting a function pointer, the
aforementioned error occurs. If this is an extern "C" function, all is ok!
fnunmdll_2(pCB);
return 0;
}
As crazy as it sounds, I'm beginning to think this is not possible to do
with native C++ functions.
Thanks in advance, George