[英]Mongodb autoConnectRetry option in connection string is not working with C# driver
I have a quick questions here.我在这里有一个快速的问题。 I am using mongodb with C# and Java.
我在 C# 和 Java 中使用 mongodb。 Connectionstring that i use is:
我使用的连接字符串是:
mongodb.domain.com/?autoConnectRetry=true
The same connection string is working with Java but not with C#.相同的连接字符串适用于 Java,但不适用于 C#。 I saw many posts around this that, if we remove autoConnectRetry option it works fine.
我看到很多关于这个的帖子,如果我们删除 autoConnectRetry 选项它工作正常。
Looked at the logs and saw that its erroring out with below exception查看日志,发现其错误并显示以下异常
System.ArgumentException: Invalid option 'autoConnectRetry'.
Parameter name: url
at MongoDB.Driver.MongoUrlBuilder.Parse(String url)
at MongoDB.Driver.MongoUrl..ctor(String url)
at MongoDB.Driver.MongoUrl.Create(String url)
at MongoDB.Driver.MongoServer.Create(String connectionString)
Is there any alternative that can make this work?有没有其他选择可以使这项工作?
I am using .NET Framework 3.5 and Mongodb C# driver v 1.0我正在使用 .NET Framework 3.5 和 Mongodb C# 驱动程序 v 1.0
There is just no such option ("autoConnectRetry") in C# MongoDb driver, while there is in Java, so you will have to implement retry logic yourself. C# MongoDb 驱动程序中没有这样的选项(“autoConnectRetry”),而在 Java 中却有,因此您必须自己实现重试逻辑。 If you just want to use the same connection string for both and don't care about retry logic - I think that in current version of the driver it no longer throws InvalidOperationException on unknown options.
如果您只想为两者使用相同的连接字符串并且不关心重试逻辑 - 我认为在当前版本的驱动程序中,它不再对未知选项抛出 InvalidOperationException 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.