1

I have written an application that works fine when run from Visual Studio 2017, and uses the following libraries:

  • Microsoft.SqlServer.Management.Common
  • Microsoft.SqlServer.Management.Smo

But when I try to run it stand alone, I get the following error:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.ConnectionInfo, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.SqlServer.ConnectionInfo, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'

Which I traced down to missing SQL Server Management Objects collection for the SQL Server.

I need to know how to resolve this, or if it can be resolved for SQL Server Express. I noticed these packs are available for install for the purchased SQL Server versions, but have found nothing for Express.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
JeffS
  • 327
  • 7
  • 17
  • This might help https://stackoverflow.com/questions/3556379/cant-find-microsoft-sqlserver-connectioninfo-dll-assembly-file – vscoder Mar 09 '19 at 01:43

2 Answers2

2

You need to install SQLSysClrTypes.msi

UPDATED LINK https://download.microsoft.com/download/1/3/0/13089488-91FC-4E22-AD68-5BE58BD5C014/ENU/x86/SQLSysClrTypes.msi

... and maybe reboot your S.O

SQL = Structured Query Language ( sequel is just phonetics or a DB tool for Ruby )

OLD LINK http://go.microsoft.com/fwlink/?LinkID=188392&clcid=0x409

When you said "compiled executable", did you take the .exe, all .dll and all other files from bin folder? Please, copy entire content of your bin folder.

Mate
  • 4,976
  • 2
  • 32
  • 38
  • Thanks for the suggestion. Installed and rebooted. Still got the same error. it works when I launch it from Visual Studio 2017, but if I take that compiled executable and launch it on it's own, I get that error. I have no idea why, because it's using the libraries from my sequel installation. – JeffS Mar 09 '19 at 03:22
  • Ok, maybe you have another common issue. Are you using Entity framework? When you said "compiled executable", did you take the .exe, all .dll and all other files from bin folder? – Mate Mar 09 '19 at 03:29
  • Using .NET Framework 4.6.1, not using Unity Framework. It's only a single executable, no dll's. – JeffS Mar 09 '19 at 03:36
  • Please, note that I mentioned "Entity framework" and not Unity. Could you please add the line in your code that throws the error? – Mate Mar 09 '19 at 03:48
  • Not using Entity Framework. posting function below. – JeffS Mar 09 '19 at 04:41
  • omg. you were right. I didn't realize that visual studio copied the DLL's directly to the bin\Release folder and so it worked in visual studio. I just have to copy those DLL's. Assuming they are licensed as redistributable. – JeffS Mar 09 '19 at 05:00
  • 1
    Great! That's because I'm very old :P . – Mate Mar 09 '19 at 05:01
0

This is the function. DBServerTextBox.Text is @"localhost\SQLEXPRESS” DBDataTextBox.Text is the path to the DATA directory The label refreshes and Thread sleep is so I can see the lable messages before they flash past.

private void AttachDatabaseToInstance()
    {
        SqlConnection con = new SqlConnection();
        con.ConnectionString = @"Data Source=" + DBServerTextBox.Text + @";Initial Catalog=master;;Integrated Security=True;Connect Timeout=30;User ID=dbadmin;Password=dbadmin";

        ServerConnection serverconn = new ServerConnection(con);
        Server s = new Server(serverconn);

        try
        {
            con.Close();
            InstallStatusLabel.Text = "Existing connections closed";
            InstallStatusLabel.Refresh();
            System.Threading.Thread.Sleep(3000);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
        try
        {
            s.DetachDatabase("mydatabase", true);
            InstallStatusLabel.Text = "Detaching any existing mydatabase database";
            InstallStatusLabel.Refresh();
            System.Threading.Thread.Sleep(3000);
        }
        catch
        {
            MessageBox.Show("Could not find attached database");
        }
        try
        {
            s.AttachDatabase("mydatabase", new System.Collections.Specialized.StringCollection { DBDataTextBox.Text + @"\mydatabase.mdf", DBDataTextBox.Text + @"\mydatabase_log.ldf" }, AttachOptions.None);
            InstallStatusLabel.Text = "Attached mydatabase database";
            InstallStatusLabel.Refresh();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }
JeffS
  • 327
  • 7
  • 17