none
Error in System.Data since .Net Framework 4.7 RRS feed

  • Question

  • Since the installation of the .net Framework 4.7, we are experiencing a breaking problem that prevents our application from connecting to the database.

    The application was developped in 2006 - 2008 on .net Framework 2.0 and has since been migrated (without any modifications) to .net Framework 4.0 and 4.5. It uses the french version of the Framework (fr).

    When connecting to the database, we get this error :

    {"The value cannot be null." & vbCrLf & "Parameter name : value"}

    With the call stack :

     à System.String.EndsWith(String value, StringComparison comparisonType)
       à System.Data.Common.ADP.IsAzureSqlServerEndpoint(String dataSource) (System\Data\Common\AdapterUtil.cs:ligne 2566)
       à System.Data.ProviderBase.DbConnectionPool.IsBlockingPeriodEnabled()
       à System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       à System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       à System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       à System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       à System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
       à System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       à System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       à System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
       à System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
       à System.Data.SqlClient.SqlConnection.Open()

    This is the connection string used :

    Data Source=InstanceName.bd.ourcompany.local;Initial Catalog=CatalogName_A;Persist Security Info=False;Integrated Security=SSPI;Connect Timeout=90;Pooling=true; Enlist=false; Min Pool Size=0; Max Pool Size=5; Connection Lifetime=1800; Load Balance Timeout=300; Application Name=MyApplicationName;

    Looking at the source code of the Framework class identified by the error, it seems to be using some ressources strings (in an array) and the error get launched when trying to access one of those array item:

    System\Data\Common\AdapterUtil.cs :

            static internal readonly string[] AzureSqlServerEndpoints = {Res.GetString(Res.AZURESQL_GenericEndpoint),
                                                                         Res.GetString(Res.AZURESQL_GermanEndpoint),
                                                                         Res.GetString(Res.AZURESQL_UsGovEndpoint),
                                                                         Res.GetString(Res.AZURESQL_ChinaEndpoint)};
     
            // This method assumes dataSource parameter is in TCP connection string format.
            static internal bool IsAzureSqlServerEndpoint(string dataSource)
            {
                // remove server port
                int i = dataSource.LastIndexOf(',');
                if (i >= 0)
                {
                    dataSource = dataSource.Substring(0, i);
                }
     
                // check for the instance name
                i = dataSource.LastIndexOf('\\');
                if (i >= 0)
                {
                    dataSource = dataSource.Substring(0, i);
                }
     
                // trim redundant whitespaces
                dataSource = dataSource.Trim();
     
                // check if servername end with any azure endpoints
                for (i = 0; i < AzureSqlServerEndpoints.Length; i++)
                {
                    if (dataSource.EndsWith(AzureSqlServerEndpoints[i], StringComparison.OrdinalIgnoreCase))
                    {
                        return true;
                    }
                }
     
                return false;
            }

    I'm comparing installs on different workstations and cannot find the source of the issue.

    Anyone has experienced that error ?

    Thanks!

    Tuesday, October 10, 2017 3:42 PM

Answers

  • Ok I found it. And a bit shy about the source of the problem.. 

    It wasn't a corrupted install but an unfinished install... Seems that I should have been a little more patient when selecting the "French" language in the dropdown on the download page. https://www.microsoft.com/en-us/download/details.aspx?id=55168

    If you select "French" in the dropdown and immediatly click "Download", you get the english only install. If you select "French" and wait a few seconds (5-6seconds) before clicking "Download", then you get the page with the english install + the french pack. 

    Usability Issue / "code 18". 

    Thanks for the help and moral support :)


    • Marked as answer by morgie Friday, November 3, 2017 12:51 PM
    Friday, October 27, 2017 1:33 PM

All replies

  • Hi morgie,

    Thank you for posting here.

    For your question, could you provide more details?

    What is the type of your database? Is your question more related to Azure sql database?

    What is the variables Res in your code? Could you provide a simple code which could reproduce the error for us to test?

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 12, 2017 5:58 AM
    Moderator
  • Hi, 

    the database is SqlServer 2012, on premise. The code I've pasted is 100% .net framework code, that's not my code. 

    In the stack-trace I've pasted, you can see that the error come from the .net framework class System.Data.Common.AdapterUtil.cs at line 2566. You can see the source code of that class there : https://referencesource.microsoft.com/#system.data/System/Data/Common/AdapterUtil.cs,cb6b355e7571843f

    At line 2566, I can see that it does a "dataSource.EndsWith(AzureSqlServerEndpoints[i]..." and this collection (AzureSqlServerEndPoints) is loaded from some resource file (At line 2538). 

    My guess is that my .Net Framework 4.7 installation is missing a ressource file required by this library (System.Data.dll missing it's corresponding System.Data.Resource.dll) but I can't find it or find any evidence of that. 

    Thanks

    Thursday, October 12, 2017 1:35 PM
  • Hello morgie,

    Thanks for the details. I can understand the problem. However it seems I also cannot find out why this method is called. Please check the following things which in my mind could be the possible reason:

    From code level:

    1. Please create a new instance and named it with a simple name, like "testname", then change your datasource name from your code to see whether the same issue persist. Maybe something in your connectionstring triggered the method.

    2. Please tell us more details about how you connect to your database in code. Use ado.net or something else? Any details about your project so that we may be able to create a repro?

    From .NET Framework installation level:

    I don't know why you are checking the installation of your machines. Do you mean you have already tried to deploy your database on some other machines and it works there? If so, that could be a installation problem. If you haven't tested it, could you please give it a test?

    Best regards,

    Barry 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 16, 2017 5:02 AM
  • Hi, thanks for your time. 

    From a code level : 

    We are using System.Data.SqlClient with CSLA 2005 (old, i know). We first open a connection that we later provide to CSLA. The error get raised on the Open() of the SqlClient connection : 

    Dim connection As SqlClient.SqlConnection
    connection = New SqlClient.SqlConnection(InfosConfig.ConnectionString)
    connection.Open()  <-- Error get raised there. 

    This is the connectionString used : 

    InfosConfig.ConnectionString = "Data Source=ServerName.bd.capitaledev.local;Initial Catalog=Database_A;Persist Security Info=False;Integrated Security=SSPI;Connect Timeout=90;Pooling=true;PoolBlockingPeriod=NeverBlock;Enlist=false;Min Pool Size=0;Max Pool Size=5;Connection Lifetime=1800; Load Balance Timeout=300; Application Name=Username|SesssionId;"

    With this connectionString (I've added the parameter "PoolBlockingPeriod=NeverBlock"), I now have the following exception. The exception is the same but the call stack is changed a little : 

       à System.String.EndsWith(String value, StringComparison comparisonType)
       à System.Data.Common.ADP.IsAzureSqlServerEndpoint(String dataSource)
       à System.Data.SqlClient.SqlInternalConnectionTds.ShouldDisableTnir(SqlConnectionString connectionOptions)
       à System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
       à System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
       à System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling)
       à System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       à System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
       à System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       à System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       à System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       à System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       à System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
       à System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       à System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       à System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
       à System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
       à System.Data.SqlClient.SqlConnection.Open()
       [...]




    • Edited by morgie Thursday, October 19, 2017 5:57 PM
    Thursday, October 19, 2017 5:55 PM
  • @morgie,

    Have you tried my other suggestions? Especially for the deployment part. If your .NET installation corrupt then we need some tests to find out the reason. 

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, October 20, 2017 7:18 AM
  • Hi Barry, 

    I suspected a corrupted install since the string values needed are sourced from a resource file from the .net framework. But I tried another application on the same machine, an application that uses the same DAL stack, with the same connectionString, and this one can open a connection successfully. 

    So I'm now more than ever in the foggggg. Both applications target .net Framework v4.0 (not 4.7), reference the same files, share the same DAL libraries and uses the same connection string. As soon as the .net Framework 4.7 is installed on the workstation, the first application stop working with the error mentionned above while the other works fine. 

    So I don't know where to look to spot what's wrong, and I'm not sure how I could help you reproduce the problem. 

    Morgie.

    Wednesday, October 25, 2017 8:12 PM
  • Ok I found it. And a bit shy about the source of the problem.. 

    It wasn't a corrupted install but an unfinished install... Seems that I should have been a little more patient when selecting the "French" language in the dropdown on the download page. https://www.microsoft.com/en-us/download/details.aspx?id=55168

    If you select "French" in the dropdown and immediatly click "Download", you get the english only install. If you select "French" and wait a few seconds (5-6seconds) before clicking "Download", then you get the page with the english install + the french pack. 

    Usability Issue / "code 18". 

    Thanks for the help and moral support :)


    • Marked as answer by morgie Friday, November 3, 2017 12:51 PM
    Friday, October 27, 2017 1:33 PM
  • Hi Morgie,

    Seems that you have solved your problem. 

    Please kindly mark the reply that helps you as answer, this will do good to other community members with similar or same problem.

    Thanks a lot,

    Charles He


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, November 3, 2017 9:54 AM