Opened 13 years ago

Closed 12 years ago

#3561 closed Bugs (wontfix)

BadImageFormatException

Reported by: Daryl Vertigan <daryl.vertigan@…> Owned by: Anthony Williams
Milestone: Boost 1.41.0 Component: thread
Version: Boost 1.40.0 Severity: Problem
Keywords: Cc: daryl.vertigan@…

Description

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 BadImageFormatException (ie, not a valid win32 app).

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.

I have attached a minimal application to highlight the issue. Build and run TestApp to get the exception.

Attachments (1)

Test.zip (9.2 KB ) - added by Daryl Vertigan <daryl.vertigan@…> 13 years ago.

Download all attachments as: .zip

Change History (5)

by Daryl Vertigan <daryl.vertigan@…>, 13 years ago

Attachment: Test.zip added

comment:1 by daryl.vertigan@…, 13 years ago

Cc: daryl.vertigan@… added

Have reported this issue to Microsoft:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=503310

Their response is as follows:

*

Hi: this is a known issue - which may be By-Design.

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).

Another workaround would be to ask Boost how to disable static TLS, and what the consequences of doing so are.

Jonathan Caves Visual C++ Compiler Team

*

We would like to avoid having to compile dlls, so perhaps there is a way to disable/exclude thread local storage in the compilation?

in reply to:  1 comment:2 by anonymous, 13 years ago

Replying to daryl.vertigan@…:

Have reported this issue to Microsoft:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=503310

Their response is as follows:

*

Hi: this is a known issue - which may be By-Design.

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).

Another workaround would be to ask Boost how to disable static TLS, and what the consequences of doing so are.

Jonathan Caves Visual C++ Compiler Team

*

We would like to avoid having to compile dlls, so perhaps there is a way to disable/exclude thread local storage in the compilation?

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.

comment:3 by daryl.vertigan@…, 13 years ago

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.

comment:4 by Anthony Williams, 12 years ago

Resolution: wontfix
Status: newclosed

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.

Note: See TracTickets for help on using tickets.