Connecting Tech Pros Worldwide Help | Site Map

Calling C# Callbacks from C++ dll?

Member
 
Join Date: Apr 2007
Posts: 75
#1: 4 Weeks Ago
Hi Guys,
I have a C++ third party dll which does some algorithms for us and seldomly passes data back. Now we were wanting to use DLLIMPORT from c# to utilize these functions from C++ but are having some issues.

Here are the function declaration in C++.

Expand|Select|Wrap|Line Numbers
  1.  
  2. int DoWSUpdate(LPSTR lpName,LPSTR lpPath,LPSTR lpBinPath,MyCallBack pMyCallBack) 
  3.  
  4. void (CALLBACK *MyCallBack)(DWORD dStatus,LPSTR Cur,long Complete,long AllComplete,LPSTR szDescript)
  5.  
To utilize the above i have written the following c# code.

Expand|Select|Wrap|Line Numbers
  1.  
  2. public delegate void MyCallBack(int dStatus,  string Cur, long Complete, long AllComplete, string szDescript);
  3.  
  4. [DllImport("CPLUS.dll", SetLastError = true, EntryPoint = "DoWSUpdate")]
  5. public static extern int DoWSUpdate([MarshalAs(UnmanagedType.LPStr)] string lpName, [MarshalAs(UnmanagedType.LPStr)] string lpPath, [MarshalAs(UnmanagedType.LPStr)] string lpBinPath, [MarshalAs(UnmanagedType.FunctionPtr)] MyCallBack pMyCallBack);
  6.  
  7.  
Please advise what am i doing wrong here as each time i try to invoke DoWSUpdate i get

Quote:
Unable to find an entry point named 'DoWSUpdate' in DLL 'CPLUS.dll'.

Please help guys.......
Reply

Tags
c++ to c#, callbacks from c++ to c#, dllimport