我想创建一个 CLR 函数,我创建了一个普通的类库文件并编码如下,我不想使用 SqlServerProject,因为我在那里找不到一些类。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Server;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Types;
namespace ClassLibrary1
{
public partial class Class1
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString GetPassword(SqlString Value)
{
return Value;
}
}
}
我编译了代码并像这样从 sqlserver 创建了程序集
CREATE ASSEMBLY ASSEM
authorization dbo
FROM 'E:\NBM Sites\tvt.stage.asentechdev1.com\ClassLibrary1.dll' WITH PERMISSION_SET = SAFE;
并创建了如下功能
CREATE FUNCTION SampleFunc
(
@value nvarchar(max)
)
RETURNS nvarchar(max) with execute as caller
AS
External Name ASSEM.Class1.GetPassword
GO
但是上面的创建函数抛出了一个错误说。
Could not find Type 'Class1' in assembly 'ClassLibrary1'.
我不明白,为什么 class1 不被识别,因为我也公开了它。请任何人帮助我。