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