Sql-server – SQL Server Management Studio – Cannot connect – Method not found SqlConnectionInfo.set_IsActiveDirectoryUniversalAuth

sql serversql-server-2016ssmswindows

I have a fresh installation of Windows 10, on which Microsoft Visual Studio 2015 was installed (therefore, a default database was installed too). I installed SQL Server Management Studio 2016 (v13.0.16106.4) but could not connect with the following error message:

Cannot connect to MYSERVER\SQLEXPRESS.

Method not found: 'Void Microsoft.SqlServer.Management.Common.SqlConnectionInfo.set_IsActiveDirectoryUniversalAuth(Boolean)'. (ConnectionDlg)

I've since tried to:

  • Install SQL Server 2016
  • Uninstall both SQL Server 2016 and the one coming with Visual Studio 2015 (following http://intellitect.com/sql-server-2008-install-nightmare/)
  • Once everything was cleaned and after a reboot, install SQL Server 2016 with default settings
  • Repair Microsoft SQL Server Management Studio

Note that regardless of what I try to connect to (including typing junk in the server text box), I have the same message, which leads me to believe that the error happens before SSMS actually tries to connect to the server.

I'm out of ideas; it seems like a DLL file may be missing, but which one and why, I cannot say.

The only "useful" reference I have found is this technet forum post which refers to a "patch", but I can't find where this "patch" could be found, if it exists.

I can connect with sqlcmd -S mymachine\SQLEXPRESS; I can also run queries like SELECT * from sys.databases successfully.

Best Answer

Note that this answer will allow some operations, but you'll still have a broken environment.

IMPORTANT: This allows connecting to a database and running queries, but you'll still get errors inside SSMS!

I'm not saying it's pretty, but I can now use SQL Server Express 2016.

Copy the file Microsoft.SqlServer.ConnectionInfo.dll from the folder:

C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio

to this folder (I strongly suggest you backup the file first, then you can overwrite the file):

C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.ConnectionInfo\13.0.0.0__89845dcd8080cc91

Why does it work?

Note that a Microsoft engineer would better answer this question, but here's my theory: for some reason, a different release of the same version of the Microsoft.SqlServer.ConnectionInfo assembly has been released publicly (e.g. as part of Visual Studio and SQL Server Express release). The one in the GAC did not contain the SqlConnectionInfo.IsActiveDirectoryUniversalAuth property, but SQL Server Management Studio Express expects it.

What we are doing here is just replacing the version in the GAC with the version that ships with SSMS Express, so that it loads this one instead. This will affect everything that depends on that dll file, but hopefully there's no breaking changes in an assembly that has the same version number...

How did I find this?

I found which dll file the class was specified in by searching the intertubes. I then used sysinternal's procmon to look at which version of that dll was in fact loaded. I searched my computer for other potential versions of that file, and simply tried disabling versions until I had a different error. I then tried replacing it with other versions in the SSMS Express installation folder, and it worked. So here we are!

Update

It's not solving everything though... here's an error I have when right-clicking on a database and selecting property.

Cannot show requested dialog. (SqlMgmt)
Method not found: 'Microsoft.SqlServer.Management.Common.DatabaseEngineEdition Microsoft.SqlServer.Management.Smo.SqlSmoObject.get_DatabaseEngineEdition()'. (SqlManagerUI)`

I have tried installing everything in the GAC without success either: ls "C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\*.d ll" | % { &"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\gacutil.exe" /if $_.FullName }