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