Hi,

I have a C++ DLL which has exported functions which is used in a C# application via DllImport. The C++ DLL is linked to various .lib files which use boost functionality (thread, asio etc) internally and are compiled with BOOST_ALL_DYN_LINK option to work with C++\CLI

When I run the application it just hangs with following stack trace. I get the same results if I convert this to a C++\CLI DLL and use it directly from the C# application.

Stack Trace:
------------------------------------------------
OneComShim.dll!boost::asio::detail::win_thread::start_thread(boost::asio::detail
::win_thread::func_base * arg=0x035574f0, unsigned int stack_size=0x00010000)  
Line 98 + 0xe bytes C++
OneComShim.dll!boost::asio::detail::win_thread::win_thread<boost::asio::detail::
win_iocp_io_service::timer_thread_function>
(boost::asio::detail::win_iocp_io_service::timer_thread_function f={...}, 
unsigned int stack_size=0x00010000)  Line 72 C++
OneComShim.dll!boost::asio::detail::win_iocp_io_service::do_add_timer_queue(boos
t::asio::detail::timer_queue_base & queue={...})  Line 471 + 0x31 bytes C++
OneComShim.dll!boost::asio::detail::win_iocp_io_service::add_timer_queue<boost::
asio::time_traits<boost::posix_time::ptime> >
(boost::asio::detail::timer_queue<boost::asio::time_traits<boost::posix_time::pt
ime> > & queue={...})  Line 78 C++
OneComShim.dll!boost::asio::detail::deadline_timer_service<boost::asio::time_tra
its<boost::posix_time::ptime> 
>::deadline_timer_service<boost::asio::time_traits<boost::posix_time::ptime> >
(boost::asio::io_service & io_service={...})  Line 68 C++
OneComShim.dll!boost::asio::deadline_timer_service<boost::posix_time::ptime,boos
t::asio::time_traits<boost::posix_time::ptime> 
>::deadline_timer_service<boost::posix_time::ptime,boost::asio::time_traits<boos
t::posix_time::ptime> >(boost::asio::io_service & io_service={...})  Line 73
C++
OneComShim.dll!boost::asio::detail::service_registry::create<boost::asio::deadli
ne_timer_service<boost::posix_time::ptime,boost::asio::time_traits<boost::posix_
time::ptime> > >(boost::asio::io_service & owner={...})  Line 81 + 0x2f bytes
C++
OneComShim.dll!boost::asio::detail::service_registry::do_use_service(const 
boost::asio::io_service::service::key & key={...}, 
boost::asio::io_service::service * (boost::asio::io_service &)* 
factory=0x100c770d)  Line 123 + 0xc bytes C++
OneComShim.dll!boost::asio::detail::service_registry::use_service<boost::asio::d
eadline_timer_service<boost::posix_time::ptime,boost::asio::time_traits<boost::p
osix_time::ptime> > >()  Line 49 C++
OneComShim.dll!boost::asio::use_service<boost::asio::deadline_timer_service<boos
t::posix_time::ptime,boost::asio::time_traits<boost::posix_time::ptime> > >
(boost::asio::io_service & ios={...})  Line 34 C++
OneComShim.dll!boost::asio::basic_io_object<boost::asio::deadline_timer_service<
boost::posix_time::ptime,boost::asio::time_traits<boost::posix_time::ptime> > 
>::basic_io_object<boost::asio::deadline_timer_service<boost::posix_time::ptime,
boost::asio::time_traits<boost::posix_time::ptime> > >(boost::asio::io_service & 
io_service={...})  Line 91 + 0x4b bytes C++
OneComShim.dll!boost::asio::basic_deadline_timer<boost::posix_time::ptime,boost:
:asio::time_traits<boost::posix_time::ptime>,boost::asio::deadline_timer_service
<boost::posix_time::ptime,boost::asio::time_traits<boost::posix_time::ptime> > 
>::basic_deadline_timer<boost::posix_time::ptime,boost::asio::time_traits<boost:
:posix_time::ptime>,boost::asio::deadline_timer_service<boost::posix_time::ptime
,boost::asio::time_traits<boost::posix_time::ptime> > >(boost::asio::io_service 
& io_service={...})  Line 147 C++
OneComShim.dll!CORE::SERVER_COMMUNICATOR::CurlHandler::CurlHandler(CORE::SERVER_
COMMUNICATOR::ServerAgent * serverAgent=0x1029c950)  Line 37 + 0x118 bytes
C++
OneComShim.dll!CORE::SERVER_COMMUNICATOR::ServerAgent::ServerAgent()  Line 22
C++
OneComShim.dll!`dynamic initializer for 
'CORE::SERVER_COMMUNICATOR::ServerAgent::agent''()  Line 17 + 0x28 bytes
C++
TestWin.exe!TestWin.Program.Main(string[] args = {string[0x00000000]}) Line 16 + 
------------------------------------------------

As it can be seen, it stops in start_thread inside win_thread.ipp at following 
lines on WaitForSingleObject

if (entry_event)
{
  ::WaitForSingleObject(entry_event, INFINITE);
  ::CloseHandle(entry_event);
}

I am just creating a timer object in the code and do not understand why it leads 
to this situation. Also everything works fine when I use a LIB instead of DLL 
and all code is in C++.

Environment details are as follows
OS: Win XP
IDE: Visual Studio 2010
Boost version: boost_1_48_0

Regards,
Chaitanya