C# call a C++ dll get EntryPointNotFoundException
- by 5YrsLaterDBA
I was gaven a C++ dll file, a lib file and a header file. I need to call them from my C# application.
header file looks like this:
class Clog ;
class EXPORT_MACRO NB_DPSM
{
private:
string sFileNameToAnalyze ;
Clog *pLog ;
void write2log(string text) ;
public:
NB_DPSM(void);
~NB_DPSM(void);
void setFileNameToAnalyze(string FileNameToAnalyze) ;
int WriteGenbenchData(string& message) ;
};
In my C# code, I have those code:
internal ReturnStatus correctDataDLL(string rawDataFileName)
{
if (rawDataFileName == null || rawDataFileName.Length <= 0)
{
return ReturnStatus.Return_CannotFindFile;
}
else
{
setFileNameToAnalyze(rawDataFileName);
}
string msg = "";
int returnVal = WriteGenbenchData(ref msg);
return ReturnStatus.Return_Success;
}
[DllImport("..\\..\\thirdParty\\cogs\\NB_DPSM.dll")]
public static extern void setFileNameToAnalyze(string fileName);
[DllImport("..\\..\\thirdParty\\cogs\\NB_DPSM.dll")]
public static extern int WriteGenbenchData(ref string message);
I got EntryPointNotFoundException at the setFileNameToAnalyze(rawDataFileName); statement.
Few questions:
do I need to add that lib file into somewhere of my C# project? how?
do I need to add the header file into my C# project? how? (no compile error for now)
I would like to remove those "..\\..\\thirdParty\\cogs\\" hardcode path. how to this?
how to get ride of that EntryPointNotFoundException?
thanks,