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?
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?)
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
You can try this unofficial nuget package...
https://www.nuget.org/packages/Unofficial.Microsoft.SQLServer.SMO/
Install-Package Unofficial.Microsoft.SQLServer.SMO
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.
Microsoft.SqlServer.SqlManagementObjects NuGet package seams like the official way to install it after SQL Server 2017
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
In the case that you want use Backup
class add Microsoft.SqlServer.Management.SmoExtended to your project.
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
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:
- 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.
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.
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.
© 2022 - 2024 — McMap. All rights reserved.