I have two project, say named CPPDLLProject and CSharpProject.
Here in CPPDLLProject, there are few dllexport functions which can be called from CSharpProject and that calling is working fine.
But here I want to call CSharpProject's functions from CPPDLLProject so that can propagate data from C++ DLL to C# project.
Just for more explanation, Would like to add below code example. Below is the function in the C++ DLL from which would like to call C# functions.
void __stdcall CPPDLLApp::PumpMessageData(int aCode, int aType)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
if (aCode == PUMP_UPDATE_MSG && aData != NULL)
{
switch (aType)
{
case MSG_ADD:
{
// Call the C# function to send the added msg to C# project
GetCPPDLLAppMsg("MSG added");
break;
}
case MSG_DELETE:
{
// Call the C# function to send the deleted msg to C# project
GetCPPDLLAppMsg("MSG deleted");
break;
}
case MSG_UPDATE:
{
// Call the C# function to send the updated msg to C# project
GetCPPDLLAppMsg("MSG updated");
break;
}
}
}
if (aCode == PUMP_STOP_MSG)
{
// Call the C# function to send the stop msg to C# project
break;
}
if (aCode == PUMP_START_MSG)
{
// Call the C# function to send the start msg to C# project
break;
}
}
Below is the C# project's function.
public void GetCPPDLLAppMsg(string aMessage)
{
Console.WriteLine(aMessage);
}
Please suggest how to achieve this goal.
I have done few googling but no luck. My question might not be clear but any kind of help is appreciated.