Microsoft.Data.SqlClient XmlException on SqlConnection.Open - "Root element is missing"

62 Views Asked by At

We have upgraded an application to use Microsoft.Data.SqlClient from System.Data.SqlClient because we need Always Encrypted support. However, upon upgrading it is throwing an exception open attempting to create a new SqlConnection. I've tried various permutations of connection string flavor but nothing has helped.

using (var conn = new SqlConnection(@"Server=MyServer;Database=MyDb;Connect Timeout=60; uid=admin;pwd=password") //Throws XmlException - "Root element is missing"
{
    conn.Open(); 
}

Stack trace (not very helpful)

This exception was originally thrown at this call stack:
    System.Xml.XmlTextReaderImpl.Throw(System.Exception)
    System.Xml.XmlTextReaderImpl.ParseDocumentContent()
    System.Xml.XmlTextReaderImpl.Read()
    System.Xml.XmlTextReader.Read()
    System.Configuration.XmlUtil.XmlUtil(System.IO.Stream, string, bool, System.Configuration.ConfigurationSchemaErrors)
    System.Configuration.BaseConfigurationRecord.InitConfigFromFile()

Any ideas on how to fix this?

0

There are 0 best solutions below