runtime: SqlConnection: System.MissingMethodException: 'Method not found: 'Boolean System.String.Contains(Char)'.'

From @asiergonzalezgorordo on June 7, 2018 14:16

There is a missing method when targeting UWP Windows10, version 1803 imagen

Exception message:
Method not found: 'Boolean System.String.Contains(Char)'.

Stack trace:
   at System.Data.SqlClient.SNI.DataSource.InferNamedPipesInformation()
   at System.Data.SqlClient.SNI.DataSource.ParseServerName(String dataSource)
   at System.Data.SqlClient.SNI.SNIProxy.CreateConnectionHandle(Object callbackObject, String fullServerName, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Byte[]& instanceName, Byte[]& spnBuffer, Boolean flushCache, Boolean async, Boolean parallel, Boolean isIntegratedSecurity)
   at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.CreatePhysicalSNIHandle(String serverName, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Byte[]& instanceName, Byte[]& spnBuffer, Boolean flushCache, Boolean async, Boolean parallel, Boolean isIntegratedSecurity)
   at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at App3.MainPage.Page_Loaded(Object sender, RoutedEventArgs e)

Steps to reproduce

Create a UWP project Add reference to Microsoft.EntityFrameworkCore.SqlServer (this will add also a update reference of System.Data.SqlClient)

In main xaml add following code using a sql server:

SqlConnection con = new SqlConnection("Data Source=jackson;Initial Catalog=Database;user id=***;password=***;");
con.Open();

Same error appears when EFcore is used with SQL server in UWP projects. The project is that SqlClient reference has been updated and missingfunction is launched.

#region Assembly System.Data.SqlClient, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// C:\Users\agonzalezgorordo\.nuget\packages\system.data.sqlclient\**4.5.0**\ref\netstandard2.0\System.Data.SqlClient.dll
#endregion

Further technical details

EF Core version: 2.1 Database Provider: Microsoft.EntityFrameworkCore.SqlServer Operating system: Windows10 IDE: Visual Studio 2017 15.7.3

Copied from original issue: aspnet/EntityFrameworkCore#12276

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (15 by maintainers)

Most upvoted comments

Closing issue, as confirmed by @asiergonzalezgorordo and myself, this issue is resolved with the System.Data.SqlClient version 4.5.1, published on date Monday, June 18, 2018 (6/18/2018).

image

This sounds a lot like https://github.com/dotnet/corefx/pull/29970 which is being fixed in the current 2.1.1 servicing event. The underlying issue is that we shipped a newer version of the UAP assets that requires a higher underlying UWP meta-package which hasn’t shipped yet. To address this we removed those assets from the packages for now.

With last nuget update it has been solved

@keeratsingh Can you explain why this is not a SqlClient issue?

@smitpatel As confirmed, no exception is seen for System.Data.SqlClient versions 4.5.0-rc1/4.5.0 stable with Microsoft.NETCore.UniversalWindowsPlatform versions 6.1.4/6.15/6.2.0-Preview1-26502-02 while using the Min Target Version: Windows 10 Fall Creators Update (10.0; Build 16299)

The exception is only seen when the Min Target Version is updated to Windows 10, version 1803(10; Build 17134)