【问题标题】:(Unfixable) Assembly exists on SQL Server 2014 but it claims it doesn't have it(无法修复)程序集存在于 SQL Server 2014 上,但它声称它没有它
【发布时间】:2017-03-11 20:52:53
【问题描述】:

更新:此问题无法修复:https://connect.microsoft.com/SQLServer/Feedback/Details/809697

我正在尝试使用 .net 4.5 创建一个 SQL CLR 程序集,它告诉我它缺少 system.servicemodel(即使它位于 .net 程序集文件夹中):

Assembly 'MySQLCLRProject' references assembly 'system.servicemodel, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.', 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.

所以我手动将 4.5,4.5.1,4.5.2 System.ServiceModel.dll 添加到项目文件夹中,然后它告诉我它缺少 system.servicemodel.internals:

Warning: The Microsoft .NET Framework assembly 'system.servicemodel, 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 10301, Level 16, State 1, Line 13
Assembly 'MySQLCLRProject' 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.

所以我添加了一个 4.6 System.ServiceModel.dll 它会告诉我它缺少 system.xaml:

Warning: The Microsoft .NET Framework assembly 'system.servicemodel, 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 10301, Level 16, State 1, Line 13
Assembly 'MySQLCLRProject' references assembly 'system.xaml, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.', 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.

在我添加 system.xaml (4.5-4.6.1) 后,它告诉我:

Warning: The Microsoft .NET Framework assembly 'system.servicemodel, 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.
Warning: The Microsoft .NET Framework assembly 'system.xaml, 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 13
CREATE ASSEMBLY for assembly 'MySQLCLRProject' failed because assembly 'System.Xaml' 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.Xaml.AttachableMemberIdentifier::ToString][mdToken=0x6000009][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachableMemberIdentifier::Equals][mdToken=0x6000006][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachableMemberIdentifier::GetHashCode][mdToken=0x6000008][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachableMemberIdentifier::Equals][mdToken=0x6000007][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachableMemberIdentifier::.ctor][mdToken=0x6000001][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachableMemberIdentifier::get_MemberName][mdToken=0x6000002][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachableMemberIdentifier::get_DeclaringType][mdToken=0x6000003][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachableMemberIdentifier::op_Inequality][mdToken=0x6000004][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachableMemberIdentifier::op_Equality][mdToken=0x6000005][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachablePropertyServices::.cctor][mdToken=0x6000010][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachablePropertyServices::TryGetProperty[T]][mdToken=0x600000f][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachablePropertyServices::GetAttachedPropertyCount][mdToken=0x600000a][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachablePropertyServices::CopyPropertiesTo][mdToken=0x600000b][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachablePropertyServices::RemoveProperty][mdToken=0x600000c][offset 0x00000000] Code size is zero.
[ : System.Xaml.AttachablePropertyServices::SetProperty][mdToken=0x600000d][offset 0x00000000] Code size is zero.
[ : System.Xaml....

我已经搜索了所有内容,但找不到任何解决此问题的方法。我什至完全用 .net 4.5 重新创建了这个项目,但它仍然给我带来了问题。

感谢任何帮助,谢谢!

【问题讨论】:

    标签: .net sql-server sql-server-2014 sqlclr


    【解决方案1】:

    这里的问题是您正在尝试使用不受支持的 .NET Framework 库:ServiceModel。该库在 SQL Server 2005、2008 和 2008 R2 中确实有效。但是,由于它不在“支持”列表中,因此不能保证它适用于所有 .NET Framework 升级。它曾经是纯 MSIL 程序集,但后来他们将其更改为混合模式程序集,并且无法加载到 SQL Server 中。

    此问题已记录在 Stack Overflow 上:

    更多信息在这里:

    【讨论】:

    • 看起来你的帖子是解决问题的方法:dba.stackexchange.com/questions/149292/… 我必须使用httpwebrequest 使用服务,但问题是使用xmldocument,这就是我的问题所在相信(xml 序列化使用 sql server 2012 不支持的程序集)。
    • @sojim2 不,XmlDocument 很好。我以前用过。它存在于System.Xml 中,它位于supported list 中。
    • 我是手动使用 WCF 的新手,这样的东西可以与 Rest WCF 一起使用吗? stickler.de/en/information/code-snippets/… 我需要更改的只是使用 XML 阅读器而不是流阅读器。
    • @sojim2 我不会使用您提供的链接中的示例代码(在stickler.de 上)。这是糟糕的代码:不清理一次性资源,使用错误的编码(即 ASCII 而不是 UTF-8 之类的东西或其他东西)。但在一般意义上,您可能需要将StreamReader.ReadToEnd 放入一个字符串中,然后在创建XmlDocument 时使用该字符串。
    • 感谢您指出 UTF-8 编码,这将为我们省去很多麻烦。
    猜你喜欢
    • 2013-12-11
    • 1970-01-01
    • 2017-02-11
    • 2010-10-20
    • 2020-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多