无法在 SQL 中创建程序集“System.ServiceModel.Internals" [英] Failed to create assembly 'System.ServiceModel.Internals' in SQL
问题描述
我正在尝试在 SQL 中创建一个程序集,但我无法加载以下 DLL.
System.ServiceModel.Internals
创建程序集[system.servicemodel.internals]来自C:WindowsMicrosoft.NETFramework64v4.0.30319System.ServiceModel.Internals.dll"使用 permission_set = 安全;走
我收到此错误:
<块引用>消息 6218,级别 16,状态 2,第 2 行为程序集System.ServiceModel.Internals"创建程序集失败,因为程序集System.ServiceModel.Internals"验证失败.检查引用的程序集是否是最新的并且受信任(对于 external_access 或不安全)以在数据库中执行.CLR 验证器错误消息(如果有)将跟随此消息[ : System.Runtime.IOThreadScheduler+ScheduledOverlapped::.ctor][mdToken=0x6000185][offset 0x00000023][found unmanaged pointer][expected unmanaged pointer] 堆栈上的意外类型.[ : System.Runtime.IOThreadScheduler+ScheduledOverlapped::Post][mdToken=0x6000183][offset 0x0000000D][found unmanaged pointer][expected unmanaged pointer] 堆栈上的意外类型.[ : System.Runtime.IOThreadScheduler+ScheduledOverlapped::Cleanup][mdToken=0x6000184][offset 0x00000019][found unmanaged pointer][expected unmanaged pointer] 堆栈上的意外类型.[ : System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteMessageEvent][mdToken=0x6000357][offset 0x0000004B][found ref 'System.String'] 堆栈上的预期数字类型.[ : System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteEvent][mdToken=0x6000359][offset 0x0000012B] 指令无法验证.[ : System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteEvent][mdToken=0x6000359][offset 0x0000003F] 指令无法验证.[ : System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteEvent][mdToken=0x600035a][offset 0x00000061][found ref 'System.String'] 堆栈上的预期数字类型.[:System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteEvent][mdToken=0x600035b][offset 0x0000001F][found unmanaged pointer][expected unmanaged pointer] 堆栈上的意外类型.[ : System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteTransferEvent][mdToken=0x600035c][offset 0x0000007C] 指令无法验证.[ : System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteTransferEvent][mdToken=0x600035c][offset 0x000002F4][found Native Int][expected unmanaged pointer] 堆栈上的意外类型.[...
我看到了这个已解决的问题(几乎 100% 相似) 用于定义权限集.
I am trying to create an assembly in SQL but I am not able to load the following DLL.
System.ServiceModel.Internals
create assembly [system.servicemodel.internals]
from 'C:WindowsMicrosoft.NETFramework64v4.0.30319System.ServiceModel.Internals.dll'
with permission_set = safe;
go
I get this error:
Msg 6218, Level 16, State 2, Line 2 CREATE ASSEMBLY for assembly 'System.ServiceModel.Internals' failed because assembly 'System.ServiceModel.Internals' 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 [ : System.Runtime.IOThreadScheduler+ScheduledOverlapped::.ctor][mdToken=0x6000185][offset 0x00000023][found unmanaged pointer][expected unmanaged pointer] Unexpected type on the stack. [ : System.Runtime.IOThreadScheduler+ScheduledOverlapped::Post][mdToken=0x6000183][offset 0x0000000D][found unmanaged pointer][expected unmanaged pointer] Unexpected type on the stack. [ : System.Runtime.IOThreadScheduler+ScheduledOverlapped::Cleanup][mdToken=0x6000184][offset 0x00000019][found unmanaged pointer][expected unmanaged pointer] Unexpected type on the stack. [ : System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteMessageEvent][mdToken=0x6000357][offset 0x0000004B][found ref 'System.String'] Expected numeric type on the stack. [ : System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteEvent][mdToken=0x6000359][offset 0x0000012B] Instruction cannot be verified. [ : System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteEvent][mdToken=0x6000359][offset 0x0000003F] Instruction cannot be verified. [ : System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteEvent][mdToken=0x600035a][offset 0x00000061][found ref 'System.String'] Expected numeric type on the stack. [ : System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteEvent][mdToken=0x600035b][offset 0x0000001F][found unmanaged pointer][expected unmanaged pointer] Unexpected type on the stack. [ : System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteTransferEvent][mdToken=0x600035c][offset 0x0000007C] Instruction cannot be verified. [ : System.Runtime.Diagnostics.DiagnosticsEventProvider::WriteTransferEvent][mdToken=0x600035c][offset 0x000002F4][found Native Int][expected unmanaged pointer] Unexpected type on the stack. [...
I saw this solved question(almost 100% similar) Failed to CREATE AN ASSEMBLY in SQL so I tried to do the same
The .NET version of the SQL Server and the file are the same v4.0.30319
I ran the statement select * from sys.dm_clr_properties
and the result seems to be normal.
directory C:WindowsMicrosoft.NETFramework64v4.0.30319
version v4.0.30319
state CLR is initialized
SQL VERSION: 11.2.5058.0
Any idea how to create this assembly?
I need it because when I try to create a custom assembly I got this error:
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.
Have you tried installing the assembly with the UNSAFE permission set option?
I have System.ServiceModel.Internals (v4 from GAC) installed on SQL Server 11.0.5058 as UNSAFE, I don't know if you will be having versioning issues as well but I believe the assembly can only be installed as unsafe as it may access unmanaged resources.
From your error message:
[found unmanaged pointer] [expected unmanaged pointer] Unexpected type on the stack.
I understand this as Expected Unmanaged pointer, found unmanaged pointer, unmanaged pointer not allowed.
See https://msdn.microsoft.com/en-us/library/ms189566.aspx for definitions of permission sets.
这篇关于无法在 SQL 中创建程序集“System.ServiceModel.Internals"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!