Boost logo

Boost Users :

Subject: [Boost-users] [thread] C++/CLI C# mixed code: linking to libthread yields runtime exception
From: Markus Werle (numerical.simulation_at_[hidden])
Date: 2009-02-04 08:32:40


Hi!

I am pretty sure this is an issue beyond boost, rather one of those
numerous pitfalls on the way to the M$-promised land called
CanUseOldCodeAndCppInDotNet.
OTOH I have hope that someone knows about some workaround,

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 <boost/thread/thread.hpp>
#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.
regards,
Markus
[keywords C# C++/CLI CSharp mixed thread boost System.BadImageFormatException]

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net