Recently in the process of doing the project need to refer to the DLL compiled by C + + in the WinForm client project, so the related content carried out some research, a few tips summarized as follows.
The first step is to make the class library to be referenced:
(1) First to get C + + DLL, it should be noted that the DLL inside the method must conform to C-style, non-conforming can be outward re-encapsulation, otherwise unable to find entrypoint.
(2) Then on the Start menu, follow the path "Microsoft Visual Studio 2008/visual Studio tools/visual Studio 2008 Command Prompt" To open the console tool for the Visual Studio 2008 command prompt.
Enter Dumpbin-exports [C + + DLL path], where the "path of C + + DLL" can be left-click and hold the DLL into the console to produce. Press ENTER to show the methods and corresponding entrypoint that are exposed in the C + + DLL.
(3) The reference to the login interface in the class library is listed here, and the references to the other methods are similar.
Login
[DllImport ("Restapiclient4csharp", entrypoint= "[email protected]@[email Protected]")]
public static extern bool Login_4csharp (string server, String login_id, string password, string license,
StringBuilder errbuf, UInt32 errbufsize);
(4) Set the referenced C + + DLLs and Lib files to always copy content.
(5) Do some testing procedures to test, the class library is finished production.
The second step is to WinForm the client's reference to the C # class library:
Here, I come across a problem, obviously another class library project in the project needs to reference this C # class library, but after the reference, always error "Cannot find Xxx.dll module", later found that in the startup project also must reference this C # class library.
Questions about C # clients referencing C + + DLLs