-
Type: Bug
-
Resolution: Gone away
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.6.2
-
Component/s: Build
-
None
-
Environment:Windows 10 x64, Visual Studio 2019
-
Fully Compatible
Hi,
here is my full story: https://stackoverflow.com/questions/65534784/i-get-an-error-running-the-base-c-code-for-mongodb-with-windows-10-visual-stu
At this point, we use: HP OMEN 17 i7-9750H/32GB/512 RTX2060 240Hz with Windows 10 x64. Working on Visual Studio 2019.
I set up the latest drivers for C ++ (mongo-c-driver-1.17.3, mongo-cxx-driver-r3.6.2) After following these steps: http://mongoc.org/libmongoc/current/installing.html
http://mongocxx.org/mongocxx-v3/installation/windows/
How to set up Visual Studio project settings with mongo-cxx-driver?
I wrote the code according to this instruction:
http://mongocxx.org/mongocxx-v3/tutorial/
#include <cstdint> #include <iostream> #include <vector> #include <bsoncxx/json.hpp> #include <mongocxx/client.hpp> #include <mongocxx/stdx.hpp> #include <mongocxx/uri.hpp> #include <mongocxx/instance.hpp> #include <bsoncxx/builder/stream/helpers.hpp> #include <bsoncxx/builder/stream/document.hpp> #include <bsoncxx/builder/stream/array.hpp> using bsoncxx::builder::stream::close_array; using bsoncxx::builder::stream::close_document; using bsoncxx::builder::stream::document; using bsoncxx::builder::stream::finalize; using bsoncxx::builder::stream::open_array; using bsoncxx::builder::stream::open_document; int main(int, char**) { mongocxx::instance inst{}; mongocxx::client conn{ mongocxx::uri{"mongodb+srv://<username>:<password>@wipcluster.qetq2.mongodb.net/userdata?retryWrites=true&w=majority"} }; mongocxx::database db = conn["userdata"]; mongocxx::collection coll = db["test"]; auto builder = bsoncxx::builder::stream::document{}; bsoncxx::document::value doc_value = builder << "name" << "MongoDB" << "type" << "database" << "count" << 1 << "versions" << bsoncxx::builder::stream::open_array << "v3.2" << "v3.0" << "v2.6" << close_array << "info" << bsoncxx::builder::stream::open_document << "x" << 203 << "y" << 102 << bsoncxx::builder::stream::close_document << bsoncxx::builder::stream::finalize; bsoncxx::document::view view = doc_value.view(); bsoncxx::stdx::optional<mongocxx::result::insert_one> result = coll.insert_one(view); }
Finally i get:
Exception thrown at 0x00007FFC99A73B29 in Project3.exe: Microsoft C++ exception: mongocxx::v_noabi::bulk_write_exception at memory location 0x0000001D6D6FE0C0.
Unhandled exception at 0x00007FFC99A73B29 in Project3.exe: Microsoft C++ exception: mongocxx::v_noabi::bulk_write_exception at memory location 0x0000001D6D6FE0C0.
Before that, I used vcpkg with: C - 1.16.1 # 3, C ++ - 3.4.0-5 # 1
#include <iostream> #include <bsoncxx/builder/stream/document.hpp> #include <bsoncxx/json.hpp> #include <mongocxx/client.hpp> #include <mongocxx/instance.hpp> int main(int, char**) { mongocxx::instance inst{}; mongocxx::client conn{mongocxx::uri{"mongodb+srv://<username>:<password>@wipcluster.qetq2.mongodb.net/userdata?retryWrites=true&w=majority"} }; bsoncxx::builder::stream::document document{}; auto collection = conn["userdata"]["organizations"]; document << "hello" << "world1"; collection.insert_one(document.view()); auto cursor = collection.find({}); for (auto&& doc : cursor) { std::cout << bsoncxx::to_json(doc) << std::endl; } }
And i get:
Unhandled exception at 0x761446D2 in nowycalkiem.exe: Microsoft C++ exception: mongocxx::v_noabi::bulk_write_exception at memory location 0x00AFE6AC.
and,
Unhandled exception at 0x761446D2 in nowycalkiem.exe: Microsoft C++ exception: mongocxx::v_noabi::query_exception at memory location 0x00AFEBB8.
This code works fine on old Lenovo G570 15.6 inch Laptop (Core i3-2310M, RAM 4GB, HDD 500GB, DVDRW, Windows 7 with VIsual Studio 2019.