.net 参考 Microsoft.SqlServer.Smo.dll
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6453415/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Reference Microsoft.SqlServer.Smo.dll
提问by SiberianGuy
I need to use Serverclass 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?
我需要使用存储在 Microsoft.SqlServer.Smo.dll 中的Server类我在通常的“引用”对话框中看不到这个程序集。我在 C:/Program Files/Microsoft SQL Server/100/SDK/Assemblies 找到它并尝试从那里引用,但 Visual Studio 抛出错误“A reference 'C:/Program Files/Microsoft SQL Server/100/SDK/无法添加程序集/Microsoft.SqlServer.Smo.dll'。请确保该文件可访问,并且它是有效的程序集或 COM 组件”。我究竟做错了什么?
回答by Mitch Wheat
C:\Program Files\Microsoft SQL Server\100\SDK\Assembliesis the correct folder location (or C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblieson 64-bit systems).
C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies是正确的文件夹位置(或C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies在 64 位系统上)。
You need to add references to:
您需要添加对以下内容的引用:
Microsoft.SqlServer.ConnectionInfo.dll
Microsoft.SqlServer.Smo.dll
Microsoft.SqlServer.Management.Sdk.Sfc.dll
Microsoft.SqlServer.SqlEnum.dll
Microsoft.SqlServer.ConnectionInfo.dll
微软.SqlServer.Smo.dll
Microsoft.SqlServer.Management.Sdk.Sfc.dll
微软.SqlServer.SqlEnum.dll
(These are the minimum files that are required to build an SMO application)
(这些是构建 SMO 应用程序所需的最少文件)
For SQL Server 2016, this location is C:\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies(for the 64bit version).
对于 SQL Server 2016,此位置是C:\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies(对于 64 位版本)。
Ref.: How to: Create a Visual C# SMO Project in Visual Studio .NET
参考:如何:在 Visual Studio .NET 中创建 Visual C# SMO 项目
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?)
SQL Server 管理对象 (SMO) 可作为相关SQL Server (20XX) 功能包的一部分下载(检查小字体,因为我不相信这些是可重新分发的?)
回答by gigi
For those who need the sql server 2014 version (version 120) you need to download and install the following packages from Microsoft:
需要sql server 2014版(120版)的用户需要从微软下载并安装以下软件包:
- 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
- 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
您可以在此页面上的 Microsoft 网站上找到所有相关信息(如 @mitch-wheat 正确建议的那样):https: //www.microsoft.com/en-gb/download/details.aspx?id =42295
回答by TWilly
You can try this unofficial nuget package...
你可以试试这个非官方的 nuget 包...
https://www.nuget.org/packages/Unofficial.Microsoft.SQLServer.SMO/
https://www.nuget.org/packages/Unofficial.Microsoft.SQLServer.SMO/
Install-Package Unofficial.Microsoft.SQLServer.SMO
安装包 Unofficial.Microsoft.SQLServer.SMO
回答by EBarr
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.
我知道这是一个老问题,但我遇到了同样的问题。@Mitch_Wheat 是正确的,您至少需要引用 4 个 SMO 程序集。然而,试图一次添加所有 4 个,给了我你列出的错误。
Adding the assemblies one at a time bypassed the error.
一次添加一个程序集绕过了错误。
回答by Dipen
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.
Microsoft SQL Server 2005 管理对象集合 管理对象集合包包括 SQL Server 2005 管理 API 的几个关键元素,包括分析管理对象 (AMO)、复制管理对象 (RMO) 和 SQL Server 管理对象 (SMO)。开发人员和 DBA 可以使用这些组件以编程方式管理 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.
您可以从 Microsoft 站点 [http://www.microsoft.com/en-us/download/details.aspx?id=11988][1] 的 Feature Pack for Microsoft SQL Server 2005 - December 2008 中获取下载页面每次都会变化,如果找不到资源,也可以从我的博客下载。
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
如果您需要http://rndp-android.blogspot.com/p/missing-microsoftsqlservermanagementsdk.html,我还在我的博客中提供了一些有关此的提示和资源
回答by Moumit
An easy way to get all 7 ddlsthat related on this issue is
获得7 ddls与此问题相关的所有内容的简单方法是
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
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
创建一个单独的 console application
download those using nuget
下载那些使用 nuget
PM> Install-Package Microsoft.SQLServer.SMO -Version 12.0.2000.8
PM> 安装包 Microsoft.SQLServer.SMO -Version 12.0.2000.8
build the application and all dllswill be in the binfolder ... you can copy from there and add reference to your existing application
构建应用程序,所有内容都dlls将在bin文件夹中...您可以从那里复制并添加reference to your existing application
https://www.nuget.org/packages/Microsoft.SQLServer.SMO/12.0.2000.8
https://www.nuget.org/packages/Microsoft.SQLServer.SMO/12.0.2000.8
回答by juFo
You can use: https://www.nuget.org/packages/Microsoft.SqlServer.SqlManagementObjectssee installation info: https://docs.microsoft.com/nl-be/sql/relational-databases/server-management-objects-smo/installing-smo
您可以使用:https: //www.nuget.org/packages/Microsoft.SqlServer.SqlManagementObjects查看安装信息:https: //docs.microsoft.com/nl-be/sql/relational-databases/server-management-objects -smo/安装-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.
- 安装和使用权利。您可以在您的设备上安装和使用任意数量的软件副本来设计、开发和测试您的程序。
回答by Rahul Singh
To synchronize a pull subscription on demand in Management Studio Connect to the Subscriber in Management Studio, and then expand the server node.
在 Management Studio 中按需同步请求订阅 连接到 Management Studio 中的订阅者,然后展开服务器节点。
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.
单击关闭。
回答by watbywbarif
Microsoft.SqlServer.SqlManagementObjectsNuGet package seams like the official way to install it after SQL Server 2017
Microsoft.SqlServer.SqlManagementObjectsNuGet 包接缝就像SQL Server 2017之后的官方安装方式
回答by Seyed Morteza Mousavi
In the case that you want use Backupclass add Microsoft.SqlServer.Management.SmoExtended to your project.
如果您想使用Backup类将 Microsoft.SqlServer.Management.SmoExtended 添加到您的项目中。

