I wrote a C ++ DLL wrapper to call C #. The DLL was tested and worked great with my C ++ test program.
Now integrated with C #, I got a runtime error and crashed. You cannot use the debugger to view more detailed information.
The C ++ side has only one method:
#ifdef DLLWRAPPERWIN32_EXPORTS
#define DLLWRAPPERWIN32_API __declspec(dllexport)
#else
#define DLLWRAPPERWIN32_API __declspec(dllimport)
#endif
#include "NB_DPSM.h"
extern "C" {
DLLWRAPPERWIN32_API int WriteGenbenchDataWrapper(string fileNameToAnalyze,
string parameterFileName,
string baseNameToSaveData,
string logFileName,
string& message) ;
}
on the C # side there is a definition
[DllImport("..\\..\\thirdParty\\cogs\\DLLWrapperWin32.dll")]
public static extern int WriteGenbenchDataWrapper(string fileNameToAnalyze,
string parameterFileName,
string baseNameToSaveData,
string logFileName,
ref string message);
and call:
string msg = "";
int returnVal = WriteGenbenchDataWrapper(rawDataFileName,
parameterFileName, outputBaseName, logFileName, ref msg);
I think there must be something wrong with the last parameter of the function. string&in C ++ should be ref stringin C #?
EDIT:
Do we really need extern "C"?
EDIT 2:
extern "C dll, EntryPointNotFoundException. dll DLL Export Viewer, , "int __cdecl WriteGenbenchDataWrapper ( std::..." "__cdecl"?