Markus Werle
OK, here the facts:
Win32, XP SP3, using Visual Studio 2008 SP1 with boost_1_37_0
I create a solution containing a C++/CLI project and a C# project, which references the C++/CLI project. Now if the C++/CLI project simply links to libboost_thread*, either via autolink or via explicit configuration, the compiler creates an executable which fails to start in both configurations, Debug and Release. The debugger catches a System.BadImageFormatException. Something went plain wrong.
OTOH adding the source files contained in \libs\thread\src\win32 to the project, defining BOOST_ALL_NO_LIB and adding
--- #pragma managed(push, off) extern "C" void tss_cleanup_implemented(void) {} #include
#pragma managed(pop) --- in a cpp file yields a working executable. Scratching my head.
Do you have any hint why linking to libboost_thread leads to this weird behaviour? Any idea what I might try? I can provide a stripped down project solution as zip-file on request.
The problem is that the static boost thread library tries to hook the native win32 PE TLS callbacks in order to ensure that the thread-local data used by boost thread is cleaned up correctly. This is not compatible with a C++/CLI executable. Your workaround explicitly omits the automatic TLS cleanup (and declares that you're doing it yourself by calling on_thread_exit at the appropriate time). Anthony -- Author of C++ Concurrency in Action | http://www.manning.com/williams just::thread C++0x thread library | http://www.stdthread.co.uk Just Software Solutions Ltd | http://www.justsoftwaresolutions.co.uk 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976