Boost C++ Libraries: Ticket #3561: BadImageFormatException https://svn.boost.org/trac10/ticket/3561 <p> When I create a managed C++ library that includes any of the boost thread headers, the dll cannot be loaded by C# at run time, giving a <a class="missing wiki">BadImageFormatException</a> (ie, not a valid win32 app). </p> <p> The problem occurs in debug and release for boost 1.38 and 1.40 and on VS2005 (with and without sp1), vs2008 and vs2010 beta 1. </p> <p> I have attached a minimal application to highlight the issue. Build and run <a class="missing wiki">TestApp</a> to get the exception. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3561 Trac 1.4.3 Daryl Vertigan <daryl.vertigan@…> Mon, 26 Oct 2009 01:57:49 GMT attachment set https://svn.boost.org/trac10/ticket/3561 https://svn.boost.org/trac10/ticket/3561 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">Test.zip</span> </li> </ul> Ticket daryl.vertigan@… Tue, 03 Nov 2009 00:14:22 GMT cc set https://svn.boost.org/trac10/ticket/3561#comment:1 https://svn.boost.org/trac10/ticket/3561#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">daryl.vertigan@…</span> added </li> </ul> <p> Have reported this issue to Microsoft: </p> <blockquote> <p> <a class="ext-link" href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=503310"><span class="icon">​</span>http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=503310</a> </p> </blockquote> <p> Their response is as follows: </p> <p> <strong></strong>* </p> <p> Hi: this is a known issue - which may be By-Design. </p> <p> Using the Boost DLLs is probably the best workaround (especially considering that /clr and /MT[d] don't mix, so you're using the CRT DLLs already). </p> <p> Another workaround would be to ask Boost how to disable static TLS, and what the consequences of doing so are. </p> <p> Jonathan Caves Visual C++ Compiler Team </p> <p> <strong></strong>* </p> <p> We would like to avoid having to compile dlls, so perhaps there is a way to disable/exclude thread local storage in the compilation? </p> Ticket anonymous Sun, 22 Nov 2009 17:02:58 GMT <link>https://svn.boost.org/trac10/ticket/3561#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3561#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/3561#comment:1" title="Comment 1">daryl.vertigan@…</a>: </p> <blockquote class="citation"> <p> Have reported this issue to Microsoft: </p> <blockquote> <p> <a class="ext-link" href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=503310"><span class="icon">​</span>http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=503310</a> </p> </blockquote> <p> Their response is as follows: </p> <p> <strong></strong>* </p> <p> Hi: this is a known issue - which may be By-Design. </p> <p> Using the Boost DLLs is probably the best workaround (especially considering that /clr and /MT[d] don't mix, so you're using the CRT DLLs already). </p> <p> Another workaround would be to ask Boost how to disable static TLS, and what the consequences of doing so are. </p> <p> Jonathan Caves Visual C++ Compiler Team </p> <p> <strong></strong>* </p> <p> We would like to avoid having to compile dlls, so perhaps there is a way to disable/exclude thread local storage in the compilation? </p> </blockquote> <p> I'm not sure we can extract TLS as it is used internally to access the current thread on all the functions found on the this_thread namespace. </p> </description> <category>Ticket</category> </item> <item> <author>daryl.vertigan@…</author> <pubDate>Sun, 22 Nov 2009 22:38:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3561#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3561#comment:3</guid> <description> <p> I expected as much, but thanks for looking at it. Might need to leave it as a known issue unless some other workaround can be found. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Anthony Williams</dc:creator> <pubDate>Thu, 10 Jun 2010 08:26:02 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3561#comment:4 https://svn.boost.org/trac10/ticket/3561#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> Static linking of boost.thread is not supported with /clr, due to this TLS issue. If you want to use Boost.Thread with managed code you will need to use the DLL version. </p> Ticket