Using the SSMS ConnectionDialog
Published Jan 15 2019 04:44 PM 271 Views
First published on MSDN on Aug 12, 2015

I was attempting to add the SSMS connection dialog to my utility and ran into problems with referenced assemblies.

The ConnectionDialog is documented here: ...

The following is a snippet using the SSMS ConnectionDialog in a C# application.


ConnectionDialog dlg = new Microsoft.SqlServer.Management.UI.ConnectionDlg.ConnectionDialog();


UIConnectionInfo connInfo = new Microsoft.SqlServer.Management.Smo.RegSvrEnum.UIConnectionInfo { ApplicationName = "My App" };

IDbConnection conn;
dlg.AddServer(new Microsoft.SqlServer.Management.UI.ConnectionDlg.SqlServerType());
dlg.Text = "Connect to My Database";

DialogResult dr = dlg.ShowDialogValidateConnection(this, ref connInfo, out conn);
if (DialogResult.OK == dr)
m_strConnString = conn.ConnectionString + ";Pooling=TRUE";
if(false == m_strConnString.Contains("Database="))
m_strConnString += ";Database=MyDb";

bRC = true;
bRC = false;

To compile the properly, references to the RegSvrEnum and ManagementControls are required.   I compiled it on my system and provided it to a peer, who quickly caused the application to fail with missing assembly references.

I built the application using the SQL Server SSMS 2015 July Preview and they had SQL Server 2014 on their system.   No problem I made sure both assemblies were in the same directory as my application but this still failed.

Following the trail of missing assemblies I had to provide the following in order for the application to execute.

  • Microsoft.SqlServer.Management.Controls
  • Microsoft.SqlServer.Management.UserSettings
  • Microsoft.SqlServer.RegSvrEnum
  • SqlWorkbbench.Interfaces

There is not a redistributable package containing these assemblies.  The supported way is to install the matching SSMS package on the target system.   SSMS can be installed separately using the following link:

Bob Dorr - Principal SQL Server Escalation Engineer

Version history
Last update:
‎Jan 15 2019 04:44 PM
Updated by: