Skip to content

Nullreference error when failoverpartner is set #587

@gunnarif

Description

@gunnarif

If "Failover Partner" is set in the connection string sql client fails with null reference error

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Microsoft.Data.SqlClient
  StackTrace:
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginWithFailover(Boolean useFailoverHost, ServerInfo primaryServerInfo, String failoverHost, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) in D:\Projects\SqlClient\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlInternalConnectionTds.cs:line 1654
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) in D:\Projects\SqlClient\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlInternalConnectionTds.cs:line 1299

  This exception was originally thrown at this call stack:
    Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginWithFailover(bool, Microsoft.Data.SqlClient.ServerInfo, string, string, System.Security.SecureString, bool, Microsoft.Data.SqlClient.SqlConnectionString, Microsoft.Data.SqlClient.SqlCredential, Microsoft.Data.ProviderBase.TimeoutTimer) in SqlInternalConnectionTds.cs
    Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(Microsoft.Data.ProviderBase.TimeoutTimer, Microsoft.Data.SqlClient.SqlConnectionString, Microsoft.Data.SqlClient.SqlCredential, string, System.Security.SecureString, bool) in SqlInternalConnectionTds.cs

Looking at the source code RoutingInfo is being used when it is null.

To reproduce

Set failover partner in the connection string
Using sql server 2012, don't know if that has any affect

Expected behavior

Connect to sql server

Further technical details

Current source
.NET target: DotCore 3.1
SQL Server version: SQL Server 2012
Operating system: Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions