Memcpy exception when integration GET code into an existing C++ solution

May 16, 2014 at 9:45 PM
Edited May 19, 2014 at 11:50 AM
I am using VS2010 and Casablanca version 1.2 to integrate a REST interface into an existing C++ solution. If I create a new solution with only this block of code it works flawlessly. When I drop this code into an existing .cpp file it crashes on the create of the client object with a memcpy exception. I have done the updates the props file to look at the correct version of Casablanca (100) and added my external dependencies as well the paths for the include and lib directories.

The block of code is:
   http_client_config cimconfig;

               http_client cimclient(L"",cimconfig);

   cimclient .request(methods::GET).then([](http_response response) {
      string_t theResponse = response.to_string();
catch( const http_exception &e )
     printf("Exception status code %u returned. %s\n", e.error_code(), e.what());
When the call to create the cimclient is called I get the exception. If I remove the references to the config and only call http_client cimclient(L"") it seems to work ok but them it will throw the exception on the .request.

The call stack for the exception is below.

msvcr100d.dll!_VEC_memcpy(void * dst, void * src, int len) + 0x46 bytes C
cpprest100d_1_2.dll!_wmemcpy() + 0x31 bytes
cpprest100d_1_2.dll!std::char_traits<wchar_t>::copy() + 0x2f bytes
cpprest100d_1_2.dll!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> ::assign() + 0xb7 bytes
cpprest100d_1_2.dll!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> ::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >() + 0x86 bytes
cpprest100d_1_2.dll!web::http::client::credentials::credentials() + 0x67 bytes
cpprest100d_1_2.dll!web::http::client::http_client_config::http_client_config() + 0x6c bytes
cpprest100d_1_2.dll!web::http::client::details::_http_client_communicator::_http_client_communicator() + 0x73 bytes cpprest100d_1_2.dll!web::http::client::details::winhttp_client::winhttp_client() + 0x52 bytes
cpprest100d_1_2.dll!std::tr1::_Ref_count_obj<web::http::client::details::winhttp_client>::_Ref_count_obj<web::http::client::details::winhttp_client><web::http::uri const &,web::http::client::http_client_config const &>() + 0xa6 bytes
cpprest100d_1_2.dll!std::tr1::make_shared<web::http::client::details::winhttp_client,web::http::uri const &,web::http::client::http_client_config const &>() + 0x8f bytes
cpprest100d_1_2.dll!web::http::client::http_network_handler::http_network_handler() + 0x70 bytes
cpprest100d_1_2.dll!std::tr1::_Ref_count_obj<web::http::client::http_network_handler>::_Ref_count_obj<web::http::client::http_network_handler><web::http::uri const &,web::http::client::http_client_config const &>() + 0xa3 bytes
cpprest100d_1_2.dll!std::tr1::make_shared<web::http::client::http_network_handler,web::http::uri const &,web::http::client::http_client_config const &>() + 0x8c bytes
cpprest100d_1_2.dll!web::http::client::http_client::build_pipeline() + 0x6f bytes
cpprest100d_1_2.dll!web::http::client::http_client::http_client() + 0x74 bytes
Hl7.exe!CChartSchedule::sendScheduleToCIM(QMsgSchedule * pMsg) Line 146 + 0x35 bytes C++

I have searched high and low to try and find a solution to this error with no avail. I think it may be a setting somewhere in the project settings but I have compared the stand alone project to my integrated project and can't come up with anything.

Any help or suggestions of where to look would be greatly appreciated.


May 19, 2014 at 6:17 PM
Hi Sandy,

Here is an idea to help. I'm not entirely sure, but it sounds like you might have a binary mismatch problem. Are you mixing debug/release binaries in your solution? How about you try using our Nuget package for version 1.2, then this would be take care of for you. Since 1.2 is an older version, you will need to explicitly specify the C++ Rest SDK Nuget package version instead of just getting the latest. Here are the steps:
  1. Go to 'Tools'->'Library Package Manager'->'Package Manager Console'.
  2. Then at the prompt enter: Install-Package cpprestsdk -Version 1.2.0
That will install the 1.2.0 version and you should be all set. Let me know if that works.