I was a gaven C ++ dll file, file liband header file. I need to call them from my C # application.
lib
The header file is as follows:
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 the 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 received EntryPointNotFoundExceptionthe instructions setFileNameToAnalyze(rawDataFileName);.
EntryPointNotFoundException
setFileNameToAnalyze(rawDataFileName);
A few questions:
Do I need to add this file libto some of my C # project? as?
Do I need to add a header file to my C # project? as? (no compilation error yet)
I would like to remove this "..\\..\\thirdParty\\cogs\\"hardcode path . how to do it?
"..\\..\\thirdParty\\cogs\\"
How to get to this EntryPointNotFoundException?
thank,
, lib #. .
, EntryPointNotFound, , . ++, , . ( dumpbin.exe, .)
, , , DLL, , ++. "setFileNameToAnalyze" "WriteGenbenchData" - , . , NB_DPSM.
, , P/Invoke, , , . ++ DLL.
(3) , , NB_DPSM.dll bin, .
( ) extern "C" { ... }.
extern "C" { ... }
#. ( [DllImport])
[DllImport]
dll ++ , dll 1
extern "C" int GenBenchData( const string &filename, string & message ){ NB_DPSM builder; builder.setFileNameToAnalyze(filename); return builder.WriteGenbenchData( message ); }
# ,
[DllImport("shim.dll", CharSet = CharSet.Auto)] static extern int GenBenchData([MarshalAs(UnmanagedType.LPStr)]string filename, StringBuilder message);
. DLL ++, (, depend.exe, ). ++ , . ++, ++ DLL. C, ( : # 64 C/++ - 32 )
Source: https://habr.com/ru/post/1750189/More articles:Synchronizing the ERWin model with the Visual Studio 2008 GDR 2/2010 db project - version-controlAndroid ScrollView jumps when resizing - androidAdmin auto-generation - phpTrying fadein divs in sequence over time using jQuery - jqueryJSP:: Confused с объектами сеанса - javaSQL query does not take values more than 2100 - c #Является ли концепция дизайна слоев изобретенной? - designTest development: writing tests for private / protected variables - variablesОбновить пути уже созданных вложений скрепки - ruby-on-railsArray Cakephp Model Implementation - csvAll Articles