无法在 SQL 中创建程序集 'System.ServiceModel.Internals'
Failed to create assembly 'System.ServiceModel.Internals' in SQL
我正在尝试在 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
我收到这个错误:
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.
[...
我看到了这个已解决的问题(几乎 100% 相似)Failed to CREATE AN ASSEMBLY in SQL 所以我也尝试这样做
SQL服务器的.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.
[found ref 'System.String'] Expected numeric type on the stack
堆栈跟踪讲述了这个故事,CLR 验证器检查了堆栈并发现了一个意外的类型,一个字符串而不是数字。这很糟糕。正在执行的相关方法,堆栈跟踪不完整,所以我们无法一直跟踪它,是 System.Runtime.Diagnostics.DiagnosticsEventProvider.WriteTransferEvent().
这是 .NET Framework 中的 .NET 4 添加,它支持 ETW(Windows 的事件跟踪)。反汇编器可以通过多个层显示使用它的代码,例如 System.ServiceModel.Channels.HttpRequestContext.TraceHttpMessageReceived() 调用它。
换句话说,我们牢牢掌握在 WCF 领域,它通过 HTTP 接收消息并生成 ETW 事件,因此可以通过 ETW 工具进行跟踪。调用源自 System.ServiceModel.dll,核心 WCF 程序集,ETW 跟踪代码位于 System.ServiceModel.Internals.dll.
因此,不知何故,考虑到问题的性质,这怎么会发生已成定局,SQL 服务器计算机对这些 WCF 程序集有两个不同的修订版。它们通常 成对分发,是基本 .NET 安装的一部分。自 .NET 4.0 RTM 以来,已经有许多修订,版本 4.01、4.02、4.03 通过 Windows 更新滑流,例如,这些更新特别影响 System.ServiceModel。更不用说从那时起发布的版本 4.5、4.5.1、4.5.2 和 4.6,以及一些修复错误和修补安全问题的知识库更新。
期待下一个问题:那么 System.ServiceModel.Internals.dll 的 正确 修订版是什么?您可以致电 Microsoft 支持,他们会告诉您:"there isn't one"。但你已经知道了。所以不要这样做。如果无论如何你都想尝试让它工作,那么一个基本策略是 首先 查看 System.ServiceModel 的修订号,然后尝试找到 System.ServiceModel。内部构件,其修订号如果不相等,则至少在大致范围内。您现在拥有的几乎可以肯定不是关闭版本,修订版 34234 大致是 .NET 4.5.2 修订版号。
您是否尝试过使用 UNSAFE 权限集选项安装程序集?
我在 SQL 服务器 11.0.5058 上安装了 System.ServiceModel.Internals(来自 GAC 的 v4)作为不安全的,我不知道你是否也会遇到版本控制问题,但我相信程序集只能安装为不安全的,因为它可能会访问非托管资源。
根据您的错误信息:
[找到非托管指针]
[预期的非托管指针]
堆栈上的意外类型。
我理解这是预期的非托管指针,找到非托管指针,不允许非托管指针。
有关权限集的定义,请参阅 https://msdn.microsoft.com/en-us/library/ms189566.aspx。
我正在尝试在 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
我收到这个错误:
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. [...
我看到了这个已解决的问题(几乎 100% 相似)Failed to CREATE AN ASSEMBLY in SQL 所以我也尝试这样做
SQL服务器的.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.
[found ref 'System.String'] Expected numeric type on the stack
堆栈跟踪讲述了这个故事,CLR 验证器检查了堆栈并发现了一个意外的类型,一个字符串而不是数字。这很糟糕。正在执行的相关方法,堆栈跟踪不完整,所以我们无法一直跟踪它,是 System.Runtime.Diagnostics.DiagnosticsEventProvider.WriteTransferEvent().
这是 .NET Framework 中的 .NET 4 添加,它支持 ETW(Windows 的事件跟踪)。反汇编器可以通过多个层显示使用它的代码,例如 System.ServiceModel.Channels.HttpRequestContext.TraceHttpMessageReceived() 调用它。
换句话说,我们牢牢掌握在 WCF 领域,它通过 HTTP 接收消息并生成 ETW 事件,因此可以通过 ETW 工具进行跟踪。调用源自 System.ServiceModel.dll,核心 WCF 程序集,ETW 跟踪代码位于 System.ServiceModel.Internals.dll.
因此,不知何故,考虑到问题的性质,这怎么会发生已成定局,SQL 服务器计算机对这些 WCF 程序集有两个不同的修订版。它们通常 成对分发,是基本 .NET 安装的一部分。自 .NET 4.0 RTM 以来,已经有许多修订,版本 4.01、4.02、4.03 通过 Windows 更新滑流,例如,这些更新特别影响 System.ServiceModel。更不用说从那时起发布的版本 4.5、4.5.1、4.5.2 和 4.6,以及一些修复错误和修补安全问题的知识库更新。
期待下一个问题:那么 System.ServiceModel.Internals.dll 的 正确 修订版是什么?您可以致电 Microsoft 支持,他们会告诉您:"there isn't one"。但你已经知道了。所以不要这样做。如果无论如何你都想尝试让它工作,那么一个基本策略是 首先 查看 System.ServiceModel 的修订号,然后尝试找到 System.ServiceModel。内部构件,其修订号如果不相等,则至少在大致范围内。您现在拥有的几乎可以肯定不是关闭版本,修订版 34234 大致是 .NET 4.5.2 修订版号。
您是否尝试过使用 UNSAFE 权限集选项安装程序集?
我在 SQL 服务器 11.0.5058 上安装了 System.ServiceModel.Internals(来自 GAC 的 v4)作为不安全的,我不知道你是否也会遇到版本控制问题,但我相信程序集只能安装为不安全的,因为它可能会访问非托管资源。
根据您的错误信息:
[找到非托管指针] [预期的非托管指针] 堆栈上的意外类型。
我理解这是预期的非托管指针,找到非托管指针,不允许非托管指针。
有关权限集的定义,请参阅 https://msdn.microsoft.com/en-us/library/ms189566.aspx。