Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-152

MongoConnectionStringBuilder fails at constructor using a connection string

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 0.9
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      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)

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            darkstar Pawel Krakowiak
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: