C # import C + + DLL report cannot find DLL file Masm32 call C + + class Library

Source: Internet
Author: User

Recently need to cut in C # A C + + DLL library, anyway dllimport is an error can not find the DLL file, path, function name, parameter, dllimport parameter check to confirm the error is no help, but want to use other language call try, because it is C + + DLL supposedly use C + + Try the best, this thing with masm32 development simple and quick to write a call applet with Masm32, which has a decorated name problem needs attention. Use the DUMPBIN command to view C + + DLL discovery using the default decorated name __cdecl, about masm32 how to call C + + The simplest is to use the extern "C" in C + +, unfortunately this DLL does not use the extern "C", Fortunately, the masm32 decorated name can be arbitrarily specified, syscall pressure stack order and __cdecl the same, compile the connection also does not decorate the function name, so you use Syscall do a function declaration, function name directly copy dumpbin/exports out the full name of the function, regardless of c + + in the parameter type is what to Masm32 is a DWORD resolution, the number of C + + parameters in the Masm32 declaration to fill in the corresponding number of DWORD, and then compile the link OK.

Continue to say back C # cannot find DLL file problem, run Masm32 program popup cannot find the C + + DLL depends on another DLL, so find this dependent DLL copied to C # reference directory run C # again, through.

Conclusion: C # calls unmanaged code, such as C + +, not only to ensure that the function name, parameter name, return type, and so on are correct, but also to ensure that C # can find the DLL that the unmanaged code depends on.

C # import C + + DLL report cannot find DLL file Masm32 call C + + class Library

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.