C # calls the C + + DLL export function hint that the specified module could not be found

Source: Internet
Author: User

On the X64 system, a C + + dynamic link library is written with VS2013, which provides an export function Sgfys.

After compiling to a DLL, we call its dynamic-link library in C #, and the calling code is as follows:

You are prompted to attempt to load the incorrect format. We're on that. NET project properties to configure, right-click the project--Properties--build--Target platform modified to (x86)

It can be called correctly after it is called again.

At this point we put the program to run under XP, will error "Cannot find the specified module".

We loaded the DLL with Dependency Walker and found a lack of dependency MSVCR120D.DLL

The problem is caused by dynamic compilation and static compilation of the runtime. DLL dynamic loading has a benefit, it can reduce the volume of the generated EXE file, but the disadvantage is that if the corresponding system environment variables or EXE directory in which the required DLL files cannot be found, the program will refuse to execute. and static compilation is to all the required libraries are statically compiled into the EXE file, so that can be run on all system platforms, but it also has a drawback, is that the resulting EXE file because the code has been a part of the library, So the volume will be relatively dynamically compiled EXE large (how much depends on the contents of the library to determine).


Workaround:

Right-click the appropriate project, select Properties, and in the project properties page under "Configuration Properties" under "C + +" under "code Generation", the default "multithreaded debug DLL (/MDD)", changed to "Multithreaded (/MT)", after determining, rebuild the project. The resulting EXE file is statically compiled.

C # calls the C + + DLL export function hint that the specified module could not be found

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.