2016-10-19 3 views
1

ドライバは問題なく正常にコンパイルされました。ドライバをテストする簡単なプログラムをコーディングしました。基本的に以下のコードがあります:MongoDB C++レガシードライバ1.1.2が動作しません - VS2013、Win 10、boost-1_62でコンパイルされました。

static std::vector<mongo::HostAndPort> hosts = { mongo::HostAndPort("xxxxxxxx-a0.mlab.com:xxxxx"), mongo::HostAndPort("xxxxxxxx-a1.mlab.com:xxxxx") }; 
static mongo::DBClientReplicaSet con("rs-xxxxxxxx", hosts, 0); 


std::string errmsg; 
mongo::client::initialize(); 
con.connect(); 
con.auth("dbname", "userid", "password", errmsg); 

私は問題なくコードをコンパイルしました。 exeがbebugモードで起動できず、エラー0xc000a200が返されました。私は全くデバッグできませんでした。リリースモードでは、起動時に停止しました。私は、コンソールでのブーストの警告があった気づい:

Assertion failed: px != 0, file C:\Boost\include\boost-1_62\boost/smart_ptr/scoped_ptr.hpp, line 105 

は、エラーのポップアップがありました:

MongoDB C++ Legacy Driver Error

私はデバッグを選択することができましたし、ここでプログラムが停止した場所である - 最後replica_set_monitor.cppの行:

void ReplicaSetMonitor::createIfNeeded(const string& name, const set<HostAndPort>& servers) { 
    LOG(3) << "ReplicaSetMonitor::createIfNeeded " << name; 
    boost::lock_guard<boost::mutex> lk(setsLock); 
    ReplicaSetMonitorPtr& m = sets[name]; 
    if (!m) 
     m = boost::make_shared<ReplicaSetMonitor>(name, servers); 
    // Don't need to hold the lifetime lock for safeGo as 
    // 1) we assume the monitor is created as the contract of this class is such that initialize() 
    // must have been called. 
    // 2) replicaSetMonitorWatcher synchronizes safeGo internally using the _monitorMutex 
    replicaSetMonitorWatcher->safeGo(); 
} 

助けてください!どうもありがとう!

答えて

1

mongo::client::initializeの前にのいずれかのドライバオブジェクトまたはBSONを作成する必要があります。上記のmongo::client::initializeへの呼び出しを、DBClientReplicaSetオブジェクトを宣言する場所に移動します。

+0

ありがとうございます!それでおしまい!しかし、今では例外があります: – Harold

+0

'con.auth(" dbname "、" userid "、" password "、errmsg); ':mongodrivertest.exeの0x00007FFD87F77788の未処理例外:Microsoft C++例外:メモリ位置0x00000056C6FFF070のmongo :: UserException。 – Harold

+0

プログラムが破損しました: 'bool DBClientWithCommands :: auth( << username << saslCommandPasswordFieldName << password_text << saslCommandDigestPasswordFieldName << digestPassword)); – Harold

関連する問題