Now i cannot set the call back function pointer to C# COM DLL.
Callback function made by MFC.
Please advise me how to set.
C++(MFC) code
]
delegate bool CallBack(int hwnd, int lParam);
class CMyDlg : public CDialog
{
Init()
{
cpi = NULL;
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(CLSID_InterfaceImplementation,
NULL, CLSCTX_INPROC_SERVER,
IID_IManagedInterface, (LPVOID*)&cpi);
retval = 0;
if (FAILED(hr))
{
printf("Couldn't create the instance!... 0x%x\n", hr);
}
else
{
CallBack^ myCallBack = gcnew CallBack(&Report);
cpi->SetCallback( myCallBack );
}
}
static bool Report(int hwnd, int lParam)
{
return true;
}
} ;
C# COM DLL code
namespace DLL_COM_TEST
{
public delegate bool CallBack(int hwnd, int lParam);
public interface IDLL_COM_TESTInterface
{
void Execute();
void SetCallback(CallBack funcCB);
}
public class IDLL_COM_TESTImplementation: IDLL_COM_TESTInterface
{
CallBack funcCB_E;
public void SetCallback(CallBack funcCB)
{
funcCB_E = funcCB;
}
public void Execute()
{
funcCB_E(1111, 1);
}
}
Error is here
error C3756: 'CallBack': Definition of delegate will conflict with existing symbol .
Please check 'CallBack'
'myCallBack' is not defined
error C2061: error 'CallBack'
error C2065: 'myCallBack' : is not defined
Best regards