Questions about C # clients referencing C + + DLLs

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.