diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionString.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionString.cs index 10e5fb6697..c0f16fde3d 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionString.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionString.cs @@ -703,6 +703,7 @@ internal SqlConnectionString(SqlConnectionString connectionOptions, string dataS _attestationProtocol = connectionOptions._attestationProtocol; _serverSPN = connectionOptions._serverSPN; _failoverPartnerSPN = connectionOptions._failoverPartnerSPN; + _hostNameInCertificate = connectionOptions._hostNameInCertificate; #if NETFRAMEWORK _connectionReset = connectionOptions._connectionReset; _contextConnection = connectionOptions._contextConnection; diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionTest.cs index 13fc5c22de..669e5b611d 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionTest.cs @@ -945,6 +945,15 @@ public void Open_ConnectionString_Whitespace() Assert.NotNull(ex.Message); } + [Fact] + public void Open_ConnectionString_UserInstance() + { + SqlConnection cn = new SqlConnection("User Instance=true;"); + SqlException ex = Assert.Throws(() => cn.Open()); + // Throws without access violation + Assert.NotNull(ex.Message); + } + [Fact] public void ServerVersion_Connection_Closed() {