Reference Microsoft.SqlServer.Smo.dll

帅比萌擦擦* 提交于 2019-11-27 17:30:46

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:

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.

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://docs.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://docs.microsoft.com/nl-be/sql/relational-databases/server-management-objects-smo/smo-license-terms

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!