我正在尝试在 SQL 中创建程序集,但无法加载以下 DLL。
System.ServiceModel.Internals
create assembly [system.servicemodel.internals]
from 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.ServiceModel.Internals.dll'
with permission_set = safe;
go
我收到此错误:
消息 6218,16 级,状态 2,第 2 行
程序集“System.ServiceModel.Internals”的创建程序集失败,因为程序集“System.ServiceModel.Internals”验证失败。检查引用的程序集是否是最新的且受信任(对于 external_access 或不安全)以在数据库中执行。 CLR 验证程序错误消息(如果有)将跟随此消息
[:System.Runtime.IOThreadScheduler+ScheduledOverlapped::.ctor][mdToken=0x6000185][偏移量0x00000023][找到非托管指针][预期非托管指针]堆栈上的意外类型。
[:System.Runtime.IOThreadScheduler+ScheduledOverlapped::Post][mdToken=0x6000183][偏移量0x0000000D][找到非托管指针][预期非托管指针]堆栈上的意外类型。
[:System.Runtime.IOThreadScheduler+ScheduledOverlapped::Cleanup][mdToken=0x6000184][偏移量0x00000019][找到非托管指针][预期非托管指针]堆栈上的意外类型。
[:System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteMessageEvent][mdToken=0x6000357][偏移量0x0000004B][找到引用'System.String']堆栈上预期的数字类型。
[:System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteEvent][mdToken=0x6000359][偏移0x0000012B]无法验证指令。
[:System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteEvent][mdToken=0x6000359][偏移0x0000003F]无法验证指令。
[:System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteEvent][mdToken=0x600035a][偏移量0x00000061][找到引用'System.String']堆栈上预期的数字类型。
[:System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteEvent][mdToken=0x600035b][偏移量0x0000001F][找到非托管指针][预期非托管指针]堆栈上的意外类型。
[:System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteTransferEvent][mdToken=0x600035c][偏移0x0000007C]无法验证指令。
[:System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteTransferEvent][mdToken=0x600035c][偏移量0x000002F4][找到本机Int][预期的非托管指针]堆栈上的意外类型。
[...
我看到这个已解决的问题(几乎100%相似)无法在 SQL 中创建程序集 https://stackoverflow.com/questions/7968068/failed-to-create-an-assembly-in-sql所以我也尝试做同样的事情
SQL Server 的 .NET 版本和文件相同v4.0.30319
我运行了该声明select * from sys.dm_clr_properties
结果似乎很正常。
directory C:\Windows\Microsoft.NET\Framework64\v4.0.30319\
version v4.0.30319
state CLR is initialized
SQL 版本:11.2.5058.0
知道如何创建这个程序集吗?
我需要它,因为当我尝试创建自定义程序集时出现此错误:
Assembly 'DataLoader' references assembly 'system.servicemodel.internals, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request.