Reference Microsoft.SqlServer.Smo.dll
Asked Answered
F

11

51

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?

Foresheet answered 23/6, 2011 at 11:39 Comment(1)
Since 2017 nuget package is the right approach: nuget.org/packages/Microsoft.SqlServer.SqlManagementObjectsElfriedeelfstan
O
91

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

Ostiary answered 23/6, 2011 at 11:42 Comment(1)
On a 64-bit system those files are located in: C:\Program Files (x86)\Microsoft SQL Server\100\SDK\AssembliesMajesty
J
4

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

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

Jovita answered 9/10, 2015 at 15:6 Comment(0)
C
2

You can try this unofficial nuget package...

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

Install-Package Unofficial.Microsoft.SQLServer.SMO

Changeover answered 4/2, 2016 at 15:42 Comment(0)
R
1

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.

Ramakrishna answered 29/2, 2012 at 14:32 Comment(0)
A
1

Microsoft.SqlServer.SqlManagementObjects NuGet package seams like the official way to install it after SQL Server 2017

Asthenopia answered 30/3, 2020 at 12:22 Comment(0)
S
0

You need to install following package to solve the problem , I have solved this problem twice with this package hope it may work for everyone too...

Microsoft SQL Server 2005 Management Objects Collection The Management Objects Collection package includes several key elements of the SQL Server 2005 management API, including Analysis Management Objects (AMO), Replication Management Objects (RMO), and SQL Server Management Objects (SMO). Developers and DBAs can use these components to programmatically manage SQL Server 2005.

You can get from Feature Pack for Microsoft SQL Server 2005 - December 2008 from Microsoft site [http://www.microsoft.com/en-us/download/details.aspx?id=11988][1] But the link location of download page changes every-time if you don't find resource you can download it from my blog too.

I have also provided some tips and resources about this in my blog if you want http://rndp-android.blogspot.com/p/missing-microsoftsqlservermanagementsdk.html

Scarf answered 21/12, 2012 at 5:36 Comment(0)
F
0

In the case that you want use Backup class add Microsoft.SqlServer.Management.SmoExtended to your project.

Frosted answered 5/11, 2015 at 16:32 Comment(0)
C
0

An easy way to get all 7 ddls that related on this issue is

Microsoft.SqlServer.ConnectionInfo.dll,
Microsoft.SqlServer.ConnectionInfoExtended.dll,
Microsoft.SqlServer.Management.Sdk.Sfc.dll,
Microsoft.SqlServer.Smo.dll,
Microsoft.SqlServer.SmoExtended.dll,
Microsoft.SqlServer.SqlClrProvider.dll,
Microsoft.SqlServer.SqlEnum.dll

Create a separate console application

download those using nuget

PM> Install-Package Microsoft.SQLServer.SMO -Version 12.0.2000.8

build the application and all dlls will be in the bin folder ... you can copy from there and add reference to your existing application

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

Crumple answered 2/2, 2018 at 10:32 Comment(0)
V
0

You can use: https://www.nuget.org/packages/Microsoft.SqlServer.SqlManagementObjects see installation info: https://learn.microsoft.com/nl-be/sql/relational-databases/server-management-objects-smo/installing-smo

but no idea if this is redistributable...

as it only talks about design, develop and testing:

  1. INSTALLATION AND USE RIGHTS. You may install and use any number of copies of the software on your devices to design, develop and test your programs.

https://learn.microsoft.com/nl-be/sql/relational-databases/server-management-objects-smo/smo-license-terms

Valence answered 8/2, 2018 at 14:5 Comment(0)
R
0

To synchronize a pull subscription on demand in Management Studio Connect to the Subscriber in Management Studio, and then expand the server node.

Expand the Replication folder, and then expand the Local Subscriptions folder.

Right-click the subscription you want to synchronize, and then click View Synchronization Status.

In the View Synchronization Status - : dialog box, click Start. When synchronization is complete, the message Synchronization completed is displayed.

Click Close.

Rese answered 3/5, 2018 at 14:7 Comment(0)
M
-4

Hmm. Try registering the DLL library by running this at the DOS prompt (I'm curious as to why it's not registered already. I tried using it on a Windows that had SQL2008 installed and didn't have your problem)

"c:\windows\system32\regsvr32.exe C:/Program Files/Microsoft SQL Server/100/SDK/Assemblies/Microsoft.SqlServer.Smo.dll"

You need the quotation marks because of the spaces in the directory names.

If you're running a 64-bit Windows, regsvr32.exe will be in C:\windows\syswow64\

Best of luck. Let us know if this won't help.. Thanks.

Myrtamyrtaceous answered 23/6, 2011 at 11:41 Comment(1)
I don't see the usual signs that this is a COM object container (DllRegisterServer export, OleSelfRegister VS_VERSION_INFO entry). Does it really need to be regsvr32ed? Wouldn't that have made it a COM reference not an assembly reference?Inheritrix

© 2022 - 2024 — McMap. All rights reserved.