类型或名称空间名称"Management"在名称空间"Microsoft.SqlServer"中不存在-SqlParser和VSTS自动生成 [英] The type or namespace name 'Management' does not exist in the namespace 'Microsoft.SqlServer' - SqlParser and VSTS automated builds

查看:79
本文介绍了类型或名称空间名称"Management"在名称空间"Microsoft.SqlServer"中不存在-SqlParser和VSTS自动生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用属于 Microsoft.SqlServer.Management.SqlParser.Parser 命名空间的解析器,以便解析Sql语句,但是在测试时可以正常工作;在VSTS中构建失败,并出现以下错误:

I am using the Parser that is part of Microsoft.SqlServer.Management.SqlParser.Parser namespace in order to parse a Sql statement and it works fine when testing, however; the build fails in VSTS with the following error:

错误CS0234:类型或名称空间名称管理"不存在在名称空间"Microsoft.SqlServer"中(您是否缺少程序集参考?)

Error CS0234: The type or namespace name 'Management' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)

我通过使用添加引用上下文并选择扩展来添加对 Microsoft.SqlServer.Management.SqlParser 的引用来引用该库.

I have referenced the library by adding a reference to Microsoft.SqlServer.Management.SqlParser using the add reference context and selecting Extensions.

我具有以下导入

using Microsoft.SqlServer.Management.SqlParser.Parser;

并正在执行解析器

var rst = Parser.Parse(sqlStr);  
return Json(rst.Errors, JsonRequestBehavior.AllowGet);

我假设我需要其他库才能在VSTS中构建,但不确定哪个?也许这些库不是基于VSTS构建的?请协助解决.

I am assuming I need additional libraries in order to build in VSTS but am not sure which? Perhaps these libraries does not build on VSTS? Please assist with a solution.

推荐答案

如果要定位SQL Server 2017,则需要包括

If you are targeting SQL server 2017, then you will need to include the SMO NuGet package in your project.

否则,您将需要从目标或引用的SQL Server版本和Service Pack级别的功能包中安装SharedManagementObjects.msi.

Otherwise you will need to install the SharedManagementObjects.msi from the Feature Pack of the SQL server version and service pack level you are targeting or referencing.

SQL Server 2016 SP2功能包
SQL Server 2014 SP2功能包
SQL Server 2012 SP4功能包

这篇关于类型或名称空间名称"Management"在名称空间"Microsoft.SqlServer"中不存在-SqlParser和VSTS自动生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆