如何解决 VS2013 错误 SQL71501:过程 X 对程序集 Y 的

时间:2023-05-08
本文介绍了如何解决 VS2013 错误 SQL71501:过程 X 对程序集 Y 的引用未解析?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

作为我们从 Visual Studio 2010 升级到 2013 的努力的一部分,我正在查看几个需要 EXTERNAL 访问的 SQL Server CLR 存储过程,并且为此目的被隔离在一个单独组装.我几乎可以轻松构建所有东西,但这给我带来了一些麻烦.

As a part of our effort to upgrade from Visual Studio 2010 to 2013, I am looking at a couple of SQL Server CLR stored procedures that need EXTERNAL access, and for this purpose are isolated in a separate assembly. I've got almost everything to build with little difficulty, but this is giving me some trouble.

由于有问题的程序集使用了新的 .sqlproj 项目类型显然根本不喜欢的 Web 引用,并且为了能够继续,我们决定使用 VS2010 SP1 单独构建该程序集并引用编译后的 DLL.程序集本身构建得很好,VS2013 对参考本身没有任何抱怨.

Since the assembly in question uses web references which the new .sqlproj project type apparently does not like at all, and to be able to proceed, we decided to just build that assembly separately using VS2010 SP1 and reference the compiled DLL. The assembly itself builds just fine and VS2013 has no complaints about the reference itself.

SQL CLR SP 的外观如下(请不要问我分号到底在做什么):

Here's how the SQL CLR SP looks (please don't ask me what on Earth that semicolon is doing there at the end):

using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.IO;
using System.Text;


public partial class StoredProcedures
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static int SQLCLR1(
        SqlString in1,
        SqlString in2,
        SqlString in3,
        SqlString in4,
        SqlString in5
        )
    {
        // ... code elided ... //
    }
};

和 SQL 端:

CREATE PROCEDURE [dbo].[SQLCLR1]
    @in1 [nvarchar](4000),
    @in2 [nvarchar](4000),
    @in3 [nvarchar](4000),
    @in4 [nvarchar](4000),
    @in5 [nvarchar](4000)
WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [External].[StoredProcedures].[SQLCLR1]
GO

AaronLS 的回答 给出了 AS EXTERNAL NAME 说明符的格式为:

An answer by AaronLS gives the format of the AS EXTERNAL NAME specifier as:

AS EXTERNAL NAME [AssemblyName].[ClassName].[FunctionName]

数据库项目将程序集引用为External.dll,在VS2010 项目属性中的Application 下,Assembly name"为External".在 VS2013 端,解决方案资源管理器将引用显示为简单的外部",这反映在 SqlServer -> 程序集名称下的属性窗口中.

The database project refers the assembly as External.dll, and in VS2010 project properties under Application, "Assembly name" is "External". On the VS2013 side, the Solution Explorer displays the reference as simply "External", and this is mirrored in the Properties window under SqlServer -> Assembly Name.

然而,当我尝试在 VS2013 端构建数据库项目时,它会吐出如下错误(每个 CLR SP 一个):

Yet, when I try to build the database project on the VS2013 side, it spits out errors like (one for each CLR SP):

12>D:\Source\...\SQLCLR1.proc.sql(9,16): Error:  SQL71501: Procedure: [dbo].[SQLCLR1] has an unresolved reference to Assembly [External].

构建成功缺少什么?

推荐答案

在 VS 2013 端,我不得不将 DLL 引用上的 Model Aware 属性设置为 True.

On the VS 2013 side, I had to set the Model Aware property on the DLL reference to True.

一旦我这样做了,构建就成功完成了.

Once I had done that, the build completed successfully.

这篇关于如何解决 VS2013 错误 SQL71501:过程 X 对程序集 Y 的引用未解析?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:修改现有小数位信息 下一篇:从 Visual Studio 运行时,PowerShell 脚本结果不同

相关文章

最新文章