1. 程式人生 > >C++/CLI InteOP with Boost.thread

C++/CLI InteOP with Boost.thread

 
在.net呼叫C++/CLI 編寫的InterOP程式時,如果這個InterOP程式中使用了Boost.thread,那麼很可能出現下面的問題:

異常System.BadImageFormatException :  is not a valid Win32 application

解決方案:

1. Use the DLL version of boost::threads with the following line before including any boost/thread files

#define BOOST_THREAD_USE_DLL


2. Sometimes the following could help:

#pragma unmanaged
#include <boost/thread.hpp>
#pragma managed



其中,1方法驗證通過,2方法似乎無用。