Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x64.dll'

Ocelot013 1 Reputation point
2021-06-14T07:46:55.157+00:00

I have two published environment, Staging and one for live. my published project works in test env. without any issue, but as soon as I deploy it on live env.
I also should mention that Microsoft.Data.SqlClient.SNI.x64.dll exists in \bin after deployment.

I get the following error:

ERROR 2021-06-08 16:45:34,415 455867ms ysomeController MoveNext           - System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.TdsParser' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.SNILoadHandle' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x64.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Microsoft.Data.SqlClient.SNINativeManagedWrapperX64.SNIInitialize(IntPtr pmo)
   at Microsoft.Data.SqlClient.SNILoadHandle..ctor() in H:...\Microsoft\Data\SqlClient\TdsParserSafeHandles.cs:line 19
   at Microsoft.Data.SqlClient.SNILoadHandle..cctor() in H:...\Microsoft\Data\SqlClient\TdsParserSafeHandles.cs:line 17
   --- End of inner exception stack trace ---
   at Microsoft.Data.SqlClient.TdsParser..cctor() in H:...\Microsoft\Data\SqlClient\TdsParser.cs:line 177
   --- End of inner exception stack trace ---
   at Microsoft.Data.SqlClient.TdsParser..ctor(Boolean MARS, Boolean fAsynchronous) in H:...\Microsoft\Data\SqlClient\TdsParser.cs:line 38
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) in H:...\Microsoft\Data\SqlClient\SqlInternalConnectionTds.cs:line 1831
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) in 
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,927 questions
{count} votes

17 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    6 deleted comments

    Comments have been turned off. Learn more

  2. Ahmed Hamdy 55 Reputation points
    2023-02-20T14:39:12.6433333+00:00
    This method had worked with me 👉 if this file "Microsoft.Data.SqlClient.SNI.x86.dll"
    is not exists in this path:
    "C:\Program Files (x86)\Microsoft SQL Server Management Studio 19\Common7\IDE"
    Steps:
        1.Download the file from this link https://www.mediafire.com/file/z2wjnd8vzg9vdf4/Microsoft.Data.SqlClient.SNI.x86.dll/file
        2.Copy and Past it to "C:\Program Files (x86)\Microsoft SQL Server Management Studio 19\Common7\IDE"
        3.Run the SQL Server Management Studio Management Studio 19 (Worked with me ✔)
    
    3 people found this answer helpful.

  3. Srishti Purohit 0 Reputation points Microsoft Employee
    2023-02-20T14:26:01.99+00:00

    I am also facing the same issue. I tried installing sql management 19.1.0 but it dint help and i need to revert to 18.2 version.
    I am stuck for very long now , please help


  4. Tarun Sharma 0 Reputation points
    2023-05-01T09:45:52.1533333+00:00

    You could try with Repair option instead of uninstallation of SSMS.

    For this try to uninstall from Control Panel>Programs and features. You will see option as Repair.

    Just do a Repair, it worked for me.


  5. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.