Reference Microsoft.SqlServer.Smo.dll

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? 

回答1

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

 

回答2

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

 

 

Installing SMO

This page provides information on how to install SMO for use by applications and the system requirements to use SMO.

SMO NuGet Package

Beginning with SQL Server 2017 SMO is distributed as the Microsoft.SqlServer.SqlManagementObjects NuGet package to allow users to develop applications with SMO.

This is a replacement for SharedManagementObjects.msi, which was previously released as part of the SQL Feature Pack for each release of SQL Server. Applications that use SMO should be updated to use the NuGet package instead and will be responsible for ensuring the binaries are installed with the application being developed.

Important

As mentioned on the Files and Version Numbers page, you should not install the SMO assemblies into the GAC. Doing so could cause issues with other applications which also use those versions of SMO (such as SQL Server Management Studio).

Installing the Package

See NuGet Quick Start - Use a Package for instructions and examples of installing and using a NuGet package.

System Requirements

SMO requires .NET Framework 4.0 or .NET Core 2.0 to run, so any applications using it must ensure that client machines have that version or higher installed. Some native binaries installed with the NetFx SMO libraries also require the VC 2013 runtime to be installed; that runtime is not included in the package. You can download the redist appropriate to your target architecture from https://www.microsoft.com/download/details.aspx?id=40784

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(128)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2020-06-21 Set-Cookie
2019-06-21 webstorm tools window
2019-06-21 What does the dot after dollar sign mean in jQuery when declaring variables?
2019-06-21 File upload with cropping support using Cropper --jquery file upload
2019-06-21 What is httpcontext
2019-06-21 foreach on Request.Files
2019-06-21 jQuery file upload测试
点击右上角即可分享
微信分享提示