Click here to Skip to main content
15,895,813 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am using dapper in Xamain Forms project to connect from Android application to SQL Server database on a desktop PC:
using (conn)
{
    result = await conn.QueryFirstAsync<int>(@"Select Count(*) From Balances");
}

The code was working fine and the project was left with the only modifications of updating the nuget packages

Now I get the following exception:
System.NotSupportedException

Message: Encoding 1256 data could not be found. Make sure you have correct international
codeset assembly installed and enabled.

Source: mscorlib

StackTrace: at System.Text.Encoding.GetEncoding (System.Int32 codepage) [0x0021d] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/text/encoding.cs:553 \n at System.Data.SqlClient.TdsParser.TryProcessEnvChange (System.Int32 tokenLength, System.Data.SqlClient.TdsParserStateObject stateObj, System.Data.SqlClient.SqlEnvChange[]& sqlEnvChange) [0x00246] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.cs:2291 \n at System.Data.SqlClient.TdsParser.TryRun (System.Data.SqlClient.RunBehavior runBehavior, System.Data.SqlClient.SqlCommand cmdHandler, System.Data.SqlClient.SqlDataReader dataStream, System.Data.SqlClient.BulkCopySimpleResultSet bulkCopyHandler, System.Data.SqlClient.TdsParserStateObject stateObj, System.Boolean& dataReady) [0x004f4] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.cs:1842 \n at System.Data.SqlClient.TdsParser.Run (System.Data.SqlClient.RunBehavior runBehavior, System.Data.SqlClient.SqlCommand cmdHandler, System.Data.SqlClient.SqlDataReader dataStream, System.Data.SqlClient.BulkCopySimpleResultSet bulkCopyHandler, System.Data.SqlClient.TdsParserStateObject stateObj) [0x00010] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.cs:1518 \n at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin (System.Boolean enlistOK) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs:1031 \n at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin (System.Data.SqlClient.ServerInfo serverInfo, System.String newPassword, System.Security.SecureString newSecurePassword, System.Boolean ignoreSniOpenTimeout, System.Data.ProviderBase.TimeoutTimer timeout, System.Boolean withFailover) [0x0009d] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs:1665 \n at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover (System.Data.SqlClient.ServerInfo serverInfo, System.String newPassword, System.Security.SecureString newSecurePassword, System.Boolean redirectedUserInstance, System.Data.SqlClient.SqlConnectionString connectionOptions, System.Data.SqlClient.SqlCredential credential, System.Data.ProviderBase.TimeoutTimer timeout) [0x000af] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs:1336 \n at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist (System.Data.ProviderBase.TimeoutTimer timeout, System.Data.SqlClient.SqlConnectionString connectionOptions, System.Data.SqlClient.SqlCredential credential, System.String newPassword, System.Security.SecureString newSecurePassword, System.Boolean redirectedUserInstance) [0x000b9] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs:1242 \n at System.Data.SqlClient.SqlInternalConnectionTds..ctor (System.Data.ProviderBase.DbConnectionPoolIdentity identity, System.Data.SqlClient.SqlConnectionString connectionOptions, System.Data.SqlClient.SqlCredential credential, System.Object providerInfo, System.String newPassword, System.Security.SecureString newSecurePassword, System.Boolean redirectedUserInstance, System.Data.SqlClient.SqlConnectionString userConnectionOptions, System.Data.SqlClient.SessionData reconnectSessionData, System.Boolean applyTransientFaultHandling, System.String accessToken) [0x00145] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs:384 \n at System.Data.SqlClient.SqlConnectionFactory.CreateConnection (System.Data.Common.DbConnectionOptions options, System.Data.Common.DbConnectionPoolKey poolKey, System.Object poolGroupProviderInfo, System.Data.ProviderBase.DbConnectionPool pool, System.Data.Common.DbConnection owningConnection, System.Data.Common.DbConnectionOptions userOptions) [0x0013c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlConnectionFactory.cs:135 \n at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection (System.Data.ProviderBase.DbConnectionPool pool, System.Data.Common.DbConnection owningObject, System.Data.Common.DbConnectionOptions options, System.Data.Common.DbConnectionPoolKey poolKey, System.Data.Common.DbConnectionOptions userOptions) [0x0000c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/System/Data/ProviderBase/DbConnectionFactory.cs:109 \n at System.Data.ProviderBase.DbConnectionPool.CreateObject (System.Data.Common.DbConnection owningObject, System.Data.Common.DbConnectionOptions userOptions, System.Data.ProviderBase.DbConnectionInternal oldConnection) [0x00184] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/ProviderBase/DbConnectionPool.cs:755 \n at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest (System.Data.Common.DbConnection owningObject, System.Data.Common.DbConnectionOptions userOptions, System.Data.ProviderBase.DbConnectionInternal oldConnection) [0x00040] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/ProviderBase/DbConnectionPool.cs:1616 \n at System.Data.ProviderBase.DbConnectionPool.TryGetConnection (System.Data.Common.DbConnection owningObject, System.UInt32 waitForMultipleObjectsTimeout, System.Boolean allowCreate, System.Boolean onlyOneCheckConnection, System.Data.Common.DbConnectionOptions userOptions, System.Data.ProviderBase.DbConnectionInternal& connection) [0x000a4] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/ProviderBase/DbConnectionPool.cs:1132 \n at System.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen () [0x00080] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Data.SqlClient/src/System/Data/ProviderBase/DbConnectionPool.cs:985 \n--- End of stack trace from previous location where exception was thrown ---\n\n at Dapper.SqlMapper.QueryRowAsync[T] (System.Data.IDbConnection cnn, Dapper.SqlMapper+Row row, System.Type effectiveType, Dapper.CommandDefinition command) [0x0010b] in /_/Dapper/SqlMapper.Async.cs:472 \n at UltimateStore.Android.SQL.SQLHelper.IsConnected () [0x00085] in D:\\P\\OldUltimateStore\\UltimateStore.Android\\UltimateStore.Android\\SQL\\SQLHelper.cs:253

What I have tried:

1. Changed database collation: to Arabic_100_CI_AI_KS_SC_UTF8
and to Latin1_General_100_CI_AI_KS_SC_UTF8

and to several other variants

the exception still thrown, but with different numbers (1250,1252,..etc)

2. Down graded dapper to a version dating before the last time the code worked, still exception thrown

3. Used the synchronous version of the QueryFirst

4. increased the connection timeout period
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900