C ++ / Cli: Failed to load file or assembly X or one of its dependencies. is not a Win32 application. (Exception from HRESULT: 0x800700C1)

I have a C ++ project, a C ++ \ Cli project, and a C # form creation project.
When I access the cli project from the win forms project, I can access and use the functions of the cli project. But when I include the cpp project header in the cli project, I get this runtime error from my C # project when I access the cli project.

CliWrapper.Func meta = new CliWrapper.Func(); 

This is the error I accepted:

BadImageFormatException: Failed to load file or assembly X or one of its dependencies. is not a Win32 application. (Exception from HRESULT: 0x800700C1)

I realized that #include <boost/thread.hpp> is causing the problem

+6
source share
2 answers

I found a solution:

http://marc.info/?l=boost-users&m=123425857320026

In the configuration properties → C / C ++ → preprocessor → preprocessor Definitions add BOOST_ALL_DYN_LINK to force the use of DLLs. In addition, copy the necessary DLLs to the directory in which the executable is. For instance. Copy file boost_thread-vc90-mt-gd-1_XX.dll to MyApp / bin / Debug.

+3
source

It is very likely that your C ++ project compiled as Win32, and your C # project either AnyCPU runs on a 64-bit machine, or just build x64.

Configure your C # and C ++ / CLI project to the target x86 architecture.

+2
source

Source: https://habr.com/ru/post/910327/


All Articles