Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reference Microsoft.SqlServer.Smo.dll

I need to use Server class which is stored in Microsoft.SqlServer.Smo.dll I don't see this assembly in usual References dialog. I have found it at C:/Program Files/Microsoft SQL Server/100/SDK/Assemblies and try to reference from there but Visual Studio throws an error "A reference 'C:/Program Files/Microsoft SQL Server/100/SDK/Assemblies/Microsoft.SqlServer.Smo.dll' could not be added. Please make sure that file is accessible, and that it is a valid assembly or COM component". What am I doing wrong?

like image 649
SiberianGuy Avatar asked Jun 23 '11 11:06

SiberianGuy


People also ask

Where is Microsoft SqlServer management SMO?

For SQL Server 2016, this location is C:\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies (for the 64bit version).

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.


4 Answers

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).

You need to add references to:

  • Microsoft.SqlServer.ConnectionInfo.dll

  • Microsoft.SqlServer.Smo.dll

  • Microsoft.SqlServer.Management.Sdk.Sfc.dll

  • Microsoft.SqlServer.SqlEnum.dll

(These are the minimum files that are required to build an SMO application)

For SQL Server 2016, this location is C:\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies (for the 64bit version).

Ref.: How to: Create a Visual C# SMO Project in Visual Studio .NET

The SQL Server Management Objects (SMO) are downloadable as part of the relevant SQL Server (20XX) Feature Pack (check the smallprint as I don't believe these are redistributable?)

like image 162
Mitch Wheat Avatar answered Sep 26 '22 21:09

Mitch Wheat


For those who need the sql server 2014 version (version 120) you need to download and install the following packages from Microsoft:

  • SQLSysClrTypes (x64): https://download.microsoft.com/download/1/3/0/13089488-91FC-4E22-AD68-5BE58BD5C014/ENU/x64/SQLSysClrTypes.msi
  • SharedManagementObjects(x64): https://download.microsoft.com/download/1/3/0/13089488-91FC-4E22-AD68-5BE58BD5C014/ENU/x64/SharedManagementObjects.msi

You can find all relevant info on Microsoft website on this page (as suggested correctly by @mitch-wheat ): https://www.microsoft.com/en-gb/download/details.aspx?id=42295

like image 42
gigi Avatar answered Sep 25 '22 21:09

gigi


You can try this unofficial nuget package...

https://www.nuget.org/packages/Unofficial.Microsoft.SQLServer.SMO/

Install-Package Unofficial.Microsoft.SQLServer.SMO

like image 44
TWilly Avatar answered Sep 25 '22 21:09

TWilly


I know this is an old question, but I just ran into the same issue. @Mitch_Wheat is correct that as a minimum you need references to the 4 SMO assemblies. Trying to add all 4 at once, however, gave me the error you listed.

Adding the assemblies one at a time bypassed the error.

like image 32
EBarr Avatar answered Sep 25 '22 21:09

EBarr