使用MongoDB解决名称服务器Xamarin.Forms Android时出错

时间:2019-08-27 23:20:05

标签: mongodb xamarin.forms xamarin.android

当我在Android清单中设置 android:targetSDKVersion =“ 28” 时,出现以下问题,连接到Mongo Atlas。

System.Reflection.TargetInvocationException:调用的目标引发了异常。 ---> System.AggregateException:解析名称服务器时出错---> System.ArgumentNullException:值不能为null。 参数名称:来源   在<715c2ff6913942e6aa8535593b3ef35a>:0的System.Linq.Enumerable.Where [TSource](System.Collections.Generic.IEnumerable 1[T] source, System.Func 2 [T,TResult]谓词)[0x0000d]处   在<93b57b4b99c64a96a2c065ea9ae1fc1f>:0中的DnsClient.NameServer.QueryNetworkInterfaces(System.Boolean skipIPv6SiteLocal)[0x00047]处   在<93b57b4b99c64a96a2c065ea9ae1fc1f>:0中的DnsClient.NameServer.ResolveNameServers(System.Boolean skipIPv6SiteLocal,System.Boolean fallbackToGooglePublicDns)[0x0000d]处    ---内部异常堆栈跟踪的结尾---   在<93b57b4b99c64a96a2c065ea9ae1fc1f>:0中的DnsClient.NameServer.ResolveNameServers(System.Boolean skipIPv6SiteLocal,System.Boolean fallbackToGooglePublicDns)[0x0005e]处   在<93b57b4b99c64a96a2c065ea9ae1fc1f>:0中的DnsClient.LookupClient..ctor()[0x00000]处   在<861d33dc90734b91874371b41764f591>:0中的MongoDB.Driver.Core.Configuration.ConnectionString.Resolve(System.Boolean resolveHosts)[0x00011]处   在0的MongoDB.Driver.MongoUrl.Resolve(System.Boolean resolveHosts)[0x00015]中   在MongoDB.Driver.MongoClientSettings.FromUrl(MongoDB.Driver.MongoUrl url)[0x0001b]在:0中   位于MongoDB.Driver.MongoClientSettings.FromConnectionString(System.String connectionString)[0x00006]在:0中   在MongoDB.Driver.MongoClient..ctor(System.String connectionString)[0x00000]在:0

如果我删除了 android:targetSDKVersion =“ 28” ,则该应用会正常连接,但Google Play要求我设置targetVersion后才能上传到Play商店。

我正在使用MongoDB驱动程序2.91

请提供可能的解决方案。

谢谢。

1 个答案:

答案 0 :(得分:0)

我发现从Android 8(Oreo)中,对net.dns的访问已被删除。我根据来自MongoDB 2.9驱动程序的连接字符串使用SRV查找连接到服务器。 DNSClient正在对连接字符串上的域名执行DNS查找。 DNSClient.net库中的以下问题显示了更多信息。

https://github.com/MichaCo/DnsClient.NET/issues/17

但是,我必须使用以下代码进行自定义实现才能获取DNS服务器:

Traceback (most recent call last):
  File "coreml.py", line 9, in <module>
coreml_model =    coremltools.converters.keras.convert('yolorcgz.h5',input_name_shape_dict={'input1': [1, 416, 416, 3]})
  File "/usr/local/lib/python2.7/dist-packages/coremltools/converters/keras/_keras_converter.py", line 760, in convert
custom_conversion_functions=custom_conversion_functions)
  File "/usr/local/lib/python2.7/dist-packages/coremltools/converters/keras/_keras_converter.py", line 556, in convertToSpec
custom_objects=custom_objects)
  File "/usr/local/lib/python2.7/dist-packages/coremltools/converters/keras/_keras2_converter.py", line 305, in _convert
raise ValueError(errMsg)
ValueError: Invalid input shape for image.
Please provide a finite height (H), width (W) & channel value (C) using input_name_shape_dict arg with key = 'image' and value = [None,H,W,C]
Converted .mlmodel can be modified to have flexible input shape using     coremltools.models.neural_network.flexible_shape_utils

问题消失了。