如何将具有 BouncyCastle.crypto.dll 依赖项的程序集加载到 SQL Server 2014 中?
How do I load an assembly with BouncyCastle.crypto.dll dependency into SQL Server 2014?
使用 VS2017,我创建了一个 SQL CLR dll(用于 SQL Server 2014),它间接使用 BouncyCastle.Crypto.dll
,但无法为它 CREATE ASSEMBLY
。它给出了一个警告(我希望)但是失败了
Msg 10332, Level 16, State 1, Line 85
Assembly "BouncyCastle.Crypto" was built using version v1.1.4322 of the .NET Framework. SQL Server currently uses version v4.0.30319.
Msg 6218, Level 16, State 2, Line 90
CREATE ASSEMBLY for assembly 'SqlClrBits' failed because assembly 'BouncyCastle.Crypto' 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
[ : Org.BouncyCastle.OpenSsl.PemReader::ReadObject][mdToken=0x6002e46][offset 0x00000024] The 'this' parameter to the call must be the calling method's 'this' parameter.
[ : Org.BouncyCastle.OpenSsl.PemReader::ReadObject][mdToken=0x6002e46][offset 0x00000102] The 'this' parameter to the call must be the calling method's 'this' parameter.
我之前已经成功加载过(pre-BouncyCastle),需要
CREATE ASYMMETRIC KEY MyKey ... FROM EXECUTABLE FILE ...
CREATE LOGIN MyUser FROM ASYMMETRIC KEY MyKey
GRANT EXTERNAL ACCESS ASSEMBLY TO MyUser
我也有过不舍运行
ALTER DATABASE MyDb SET TRUSTWORTHY ON
我什至已经为 BouncyCastle.Crypto
完成了 CREATE ASSEMBLY
。
那么 .. 如何将我的 SQL CLR 程序集加载到 SQL 服务器中?
当您收到 SQLCLR 错误说明 "failed verification" 时,您很可能需要将该程序集标记为 UNSAFE
。在这里,您可能需要将 BouncyCastle.Crypto.dll 和引用它的程序集标记为 UNSAFE
.
此外,您将需要在多个会话同时调用此代码的情况下对此进行测试。目前还不清楚 BouncyCastle 正在做什么,它可能正在做的事情假设每个进程有更多的分离,而不是 SQL 服务器的 CLR 主机,它是一个在所有会话之间共享的应用程序域。
使用 VS2017,我创建了一个 SQL CLR dll(用于 SQL Server 2014),它间接使用 BouncyCastle.Crypto.dll
,但无法为它 CREATE ASSEMBLY
。它给出了一个警告(我希望)但是失败了
Msg 10332, Level 16, State 1, Line 85
Assembly "BouncyCastle.Crypto" was built using version v1.1.4322 of the .NET Framework. SQL Server currently uses version v4.0.30319.Msg 6218, Level 16, State 2, Line 90
CREATE ASSEMBLY for assembly 'SqlClrBits' failed because assembly 'BouncyCastle.Crypto' 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
[ : Org.BouncyCastle.OpenSsl.PemReader::ReadObject][mdToken=0x6002e46][offset 0x00000024] The 'this' parameter to the call must be the calling method's 'this' parameter.
[ : Org.BouncyCastle.OpenSsl.PemReader::ReadObject][mdToken=0x6002e46][offset 0x00000102] The 'this' parameter to the call must be the calling method's 'this' parameter.
我之前已经成功加载过(pre-BouncyCastle),需要
CREATE ASYMMETRIC KEY MyKey ... FROM EXECUTABLE FILE ...
CREATE LOGIN MyUser FROM ASYMMETRIC KEY MyKey
GRANT EXTERNAL ACCESS ASSEMBLY TO MyUser
我也有过不舍运行
ALTER DATABASE MyDb SET TRUSTWORTHY ON
我什至已经为 BouncyCastle.Crypto
完成了 CREATE ASSEMBLY
。
那么 .. 如何将我的 SQL CLR 程序集加载到 SQL 服务器中?
当您收到 SQLCLR 错误说明 "failed verification" 时,您很可能需要将该程序集标记为 UNSAFE
。在这里,您可能需要将 BouncyCastle.Crypto.dll 和引用它的程序集标记为 UNSAFE
.
此外,您将需要在多个会话同时调用此代码的情况下对此进行测试。目前还不清楚 BouncyCastle 正在做什么,它可能正在做的事情假设每个进程有更多的分离,而不是 SQL 服务器的 CLR 主机,它是一个在所有会话之间共享的应用程序域。