Runtime problem with uri_builder

Jan 9, 2014 at 1:01 PM
I have a C++ MFC project that I upgraded from VS2010 to VS2013 with no apparent problems. But if I add even the simplest reference to uri_builder I get a runtime error in dbgheap.c. Just this does it:

uri_builder validate_uri(L"/test");

Looking at the dissambled code, the problem appears to be related to a call to the uri_builder destructor:

call web::http::uri::~uri

Is there some initialization code that I am supposed to be calling or special compile switches?

Thanks in advance for any suggestions.
Jan 9, 2014 at 7:23 PM
Okay, after some more testing with a virgin project I have discovered the problem is to do with whether MFC is linked as a DLL or a static library. With DLL it works, with static library it fails, even on the trivial project. I build my main project with MFC as a static project so that I do not have to distribute the MFC. Is there a workaround for this?
Jan 10, 2014 at 8:09 PM
Hi whudson_syntagm,

Casablanca works fine like you mention when using dynamic linking with MFC. However when you statically link to MFC and dynamically link to Casablanca (the second scenario you describe) there are two copies of the CRT in the process. This can lead to many issues, for example like allocating memory on one heap and deallocating on another.

The fix would be to statically link against Casablanca as well, but currently we don't support static linking yet. For now you will have to use dynamic linking to both MFC and Casablanca. We have a feature request that you can vote on to help us balance priorities, since this sounds like an important scenario for you.

Jan 11, 2014 at 7:47 AM

Thanks, Steve. It isn’t as big a problem for me now as it used to be. In earlier versions of my app, I distributed just the .exe so not having additional libraries to install was important. However, more recently I’ve been using InstallShield so I can just tick the redistributables I need. How does that work for Casablanca BTW? I assume I will somehow have to add that manually?



Jan 13, 2014 at 5:45 PM
Hi William,

For Casablanca you will just need to add the correct dll for whatever version (VS 2012, or VS 2013), platform (phone, desktop, store, xp), and configuration (debug, release) you are using. So for example if you were linking against cpprest110d_1_4.lib you'd need the dll cpprest110d_1_4.dll. You can take a look at this document for more information about how our file names are structured.