尝试在Xamarin中连接到MongoDB客户端时获取系统聚合异常

问题描述:

我在远程Azure服务器上有一个MongoDB数据库. 我有一个正在Xamarin上编写的应用程序,试图连接到我的远程服务器,但总是遇到如下异常:

I have a MongoDB database on a remote Azure server. I have an app I'm writing on Xamarin and I'm trying to connect to my remote server, but I always get an exception as following:

System.AggregateException:'解析名称服务器时出错(值不能为空.参数名称:source)(找不到文件"/etc/resolv.conf")'

我从以下代码行中获取了此异常:

I'm getting this exception from this line of code:

var client = new MongoClient("connection_string");

connection_string是我从我的Azure帐户获得的连接字符串,我也尝试从Mongo Compass连接到它并且它可以正常工作,因此我猜测身份验证或连接字符串都没有问题. 当然,我还具有连接到该数据库所需的MongoDB nuget.

The connection_string is the connection string I get from my Azure account, and I also tried connect to it from the Mongo Compass and it worked, so I'm guessing there's no problem of authentication or with the connection string. Of course I also have the MongoDB nugets needed for connection to this database.

任何帮助将不胜感激,谢谢!

Any help will be appreciated, Thanks!

昨天,我遇到了完全相同的错误,并且在互联网上进行了几次教程都没有成功之后,我设法通过通过Nudget安装并解决了我的问题. MongoDB的早期版本:2.7.0 ,而不是最新的版本(2.10.0).

Yesterday I was getting that exact same error, and after following several tutorial in internet without success, I managed to fix my problem by installing via Nudget an earlier version of MongoDB: 2.7.0 instead of the last (2.10.0).