-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
I'm trying to get a server instance by using the MongoConnectionStringBuilder to read the connection string from the application configuration file. It fails stating that the connection string is in wrong format, even for the simplest of connection strings. Example:
<add name="MongoDB" connectionString="mongodb://localhost" />
string connectionString = ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString;
var builder = new MongoConnectionStringBuilder(connectionString);
The second line will fail with the message of "System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0."
StackTrace:
at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, ref String keyname, ref String keyvalue)
at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey)
at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules)
at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
at MongoDB.CSharpDriver.MongoConnectionStringBuilder..ctor(String connectionString)