Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App referencing Microsoft.SqlServer.Smo requires additional assemblies to be included on Target Machine?

Tags:

.net

reference

I have a small app which references the Microsoft.SqlServer.Smo assembly (so I can display to the user a list of servers & databases to which they can connect).

My application originally referenced Microsoft.SqlServer.Smo and Microsoft.SqlServer.ConnectionInfo. Things worked as expected on my dev box.

When I installed the application on a test machine, I received a System.IO.FileNotFoundException. The details of the message included the following: Could not load file or assembly Microsoft.SqlServer.SmoEnum

I eventually resolved the issue by referencing the following assemblies in addition to the ones mentioned above:

  • Microsoft.SqlServer.SmoEnum
  • Microsoft.SqlServer.SqlEnum
  • Microsoft.SqlServer.BatchParser
  • Microsoft.SqlServer.Replication

Can anyone confirm that I do indeed need to include each of these additional assemblies in my application (and therefore install them on user's machines) even though the app builds fine on my development box without them referenced?

like image 609
Tim Lentine Avatar asked Sep 16 '08 20:09

Tim Lentine


People also ask

What is Microsoft SqlServer management SMO?

SQL Server Management Objects (SMO) is a collection of objects that are designed for programming all aspects of managing Microsoft SQL Server. SQL Server Replication Management Objects (RMO) is a collection of objects that encapsulates SQL Server replication management.

Where is Microsoft SqlServer management SMO?

C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies is the correct folder location (or C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies on 64-bit systems).

Where is Microsoft SqlServer ConnectionInfo DLL?

C:\WINDOWS\assembly\GAC_MSIL\Microsoft. SqlServer. ConnectionInfo.

What is Microsoft SQL Server Management Objects?

SQL Server Management Objects (SMO) are . NET objects introduced by Microsoft as of Microsoft SQL Server 2005, designed to allow for easy and simple programmatic management of Microsoft SQL Server. Using SMO, . NET programmers can design applications similar in functionality to Microsoft's SQL Server Management Studio.


2 Answers

You need to install two MSI files on a target machine, namely:

1) SQLSysClrTypes.msi [this one is needed for C# -> SMO GAC]

2) SharedManagementObjects.msi

For SQL Server 2014 you can dowload these here.

Also, you must make sure that the version is correct. These two files can be found with a little bit of googling. This way you don't copy anything to local & they will be resolved from GAC.

I know that this is old question, but the answers weren't satisfactory.

like image 53
Erti-Chris Eelmaa Avatar answered Oct 27 '22 04:10

Erti-Chris Eelmaa


Yes, they do need to be included. On the development machine you probably have SQL Server installed, which places those assemblies into the Global Assembly Cache. Whenever you build, Visual Studio just pulls from them from the GAC. It also assumes that the GAC of whatever computer it will be deployed on will also have those files. If not, it throws the FileNotFound exception.

like image 2
David J. Sokol Avatar answered Oct 27 '22 06:10

David J. Sokol