C ++ boost asio asynchronous functions not working inside dll

I have a simple tutorial based asio boost code that works fine when called from exe, but crashes when starting from a DLL using LoadLibrary. It crashes inside the promotion code, not my code. It will work inside its mutex stream functions in 90% of cases. Are there any restrictions when executing code inside a dll compared to exe?

This is my code:

Connection::Connection(boost::asio::io_service& ioservice)
    : m_Socket(ioservice)
    , m_Resolver(ioservice)
{
}

void Connection::ConnectTo()
{
    boost::asio::ip::tcp::resolver::query query("www.google.com", "http");
    boost::asio::ip::tcp::resolver::iterator iterator = m_Resolver.resolve(query);
    boost::asio::ip::tcp::endpoint endpoint = *iterator;

    // crashes here inside async_connect            
    m_Socket.async_connect(endpoint,
        boost::bind(&Connection::HandleConnect, shared_from_this(),
        boost::asio::placeholders::error, ++iterator));

}

void Connection::HandleConnect( const boost::system::error_code& e, 
    boost::asio::ip::tcp::resolver::iterator endpoint_iterator )
{
    // never reaches here
}

Is there a reason why this code could happen with an error inside the dll rather than exe? Please note that these are only asynchronous calls that fail. Sync is working fine

thank

+3
source share
2 answers

DLL-, , . DLL , RTL . , , , .

+1

() . boost , , . DLL, boost, , .

, ( DLL BOOST_ALL_DYN_LINK DLL, EXE). .

+1

All Articles