【问题标题】:TSQL command "Create Assembly" fails verification on SQL Server?TSQL 命令“创建程序集”在 SQL Server 上验证失败?
【发布时间】:2016-07-23 06:52:18
【问题描述】:

我正在尝试在 SQL Server 2014 中添加对 R language 的自定义支持。

我想安装 MEF,以允许这种情况发生。

我运行这个 SQL ...

CREATE ASSEMBLY [System.ComponentModel.Composition]
AUTHORIZATION [dbo]
from 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.ComponentModel.Composition.dll'
WITH PERMISSION_SET = SAFE

...但我收到此错误:

Warning: The Microsoft .NET Framework assembly 'system.componentmodel.composition, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.' you are registering is not fully tested in the SQL Server hosted environment and is not supported. In the future, if you upgrade or service this assembly or the .NET Framework, your CLR integration routine may stop working. Please refer SQL Server Books Online for more details.
Msg 6218, Level 16, State 2, Line 56
CREATE ASSEMBLY for assembly 'System.ComponentModel.Composition' failed because assembly 'System.ComponentModel.Composition' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message
[ : Microsoft.Internal.Assumes::NotNull[T]][mdToken=0x6000001][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.Assumes::NotNull[T1,T2]][mdToken=0x6000002][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.Assumes::NotNull[T1,T2,T3]][mdToken=0x6000003][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.Assumes::Null[T]][mdToken=0x6000005][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.Assumes::NotReachable[T]][mdToken=0x600000a][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.Assumes::NotNullOrEmpty][mdToken=0x6000004][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.Assumes::IsFalse][mdToken=0x6000006][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.Assumes::IsTrue][mdToken=0x6000007][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.Assumes::IsTrue][mdToken=0x6000008][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.Assumes::Fail][mdToken=0x6000009][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.AttributeServices::GetAttributes[T]][mdToken=0x600000b][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.AttributeServices::GetAttributes[T]][mdToken=0x600000c][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.AttributeServices::GetFirstAttribute[T]][mdToken=0x600000d][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.AttributeServices::GetFirstAttribute[T]][mdToken=0x600000e][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.AttributeServices::IsAttributeDefined[T]][mdToken=0x600000f][offset 0x00000000] Code size is zero.
[ : Microsoft.Internal.AttributeServices::IsAttributeDefined[T]][mdToken=0x6000010][offset 0...

【问题讨论】:

    标签: sql-server clr sql-server-2014 sqlclr


    【解决方案1】:

    原来我是using the "reference" .dll, not the actual "framework" .dll。这很好用:

    CREATE ASSEMBLY [System.ComponentModel.Composition]
    AUTHORIZATION [dbo]
    from 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.ComponentModel.Composition.dll'
    WITH PERMISSION_SET = UNSAFE
    

    为避免猜测要从哪个文件夹导入,请运行以下查询:

    select * from sys.dm_clr_properties
    

    【讨论】:

    • 如果有人发现有关reference vs actual DLL 的链接答案有用,请不要忘记为该答案投票;-)。
    • 完成!如果你能想出将混合模式程序集加载到 SQLCLR 中的方法,我会想办法给你 50 声望 :)
    • 谢谢。不幸的是,无法加载混合模式的程序集。这是一个很大的限制,它不允许加载某些框架库。是这个问题吗?
    • 我希望我可以在数据库中使用超快的 C++ 实现,但如果它包含在 C# 中,这似乎是不可能的。我得想办法。
    • 您可以通过 COM 包装器调用非托管代码。那会有帮助吗?我见过人们这样做是为了获得基本的 Windows 调用。
    猜你喜欢
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-17
    相关资源
    最近更新 更多