boost静态连接库和c++/clr不兼容问题:未能加载文件或程序集,不是有效的Win32应用程序。

转自:http://blog.csdn.net/h807892124/article/details/51326552c++

项目上遇到的问题:c++编写的类使用托管c++包装成dll提供给c#项目使用。c++须要使用boost,clr,项目目标平台都是win32/x86。开发环境win10 x64系统,vs2013,.Net Framework 4.0,boost 1.55。c#

【问题表现】c#程序在win10 x86/x64正常运行,但在win7 x86/x64运行时发生异常:
Additional information: Could not load file or assembly “LicenseClientDLL_D.dll” or one of its dependencies. is not a valid Win32 application. (Exception from HRESULT:0x800700C1)
这里写图片描述windows

【缘由】boost库默认使用静态连接方式,但boost静态连接库和C++/clr不兼容,因此要换成动态连接。
stackoverflow上相关资料:
[引用]Too many comments in the net saying boost static libs and CLR are not compatible.
[引用]It was the boost libraries having some issue when compiled without /clr but linked to a program that uses /clrapp

【解决方案】c++使用boost动态连接库。
1.在须要使用boost库的项目的“预处理器定义”增长 BOOST_THREAD_DYN_LINK (要求动态连接boost库)
2.手动拷贝须要引用的boost库文件到项目路径 libboost、boost开头的lib文件(BOOST_LIB_DIAGNOSTIC 该宏能够查看须要的boost库)
3.从新编译.net

相关文章
相关标签/搜索