GAC 中的 SQLCLR 函数和 System.Runtime.Serialization [英] SQLCLR Function and System.Runtime.Serialization In GAC

查看:28
本文介绍了GAC 中的 SQLCLR 函数和 System.Runtime.Serialization的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 C# 中构建了一个 SQLCLR 函数,它将反序列化 JSON 并返回一个表.

I've built a SQLCLR function in C# that will deserialize JSON and return a table.

我遇到的问题是在 SQL Server 2012 中获取正确的程序集.

The problem I have is getting the correct assemblies within SQL Server 2012.

为了使用 Newtonsoft 的反序列化器,我必须将以下程序集添加到 SQL Server:

In order to utilize Newtonsoft's deserializer I've had to add the following assemblies to SQL Server:

System.ServiceModel.Internals.dll
SMDiagnostics.dll
System.Runtime.Serialization.dll
Newtonsoft.Json.dll

这一切都按计划进行,但是当我尝试运行我的函数时,出现以下错误:

This has all gone as planned but when I try to run my function I get the following error:

System.IO.FileLoadException:无法加载文件或程序集System.Runtime.Serialization,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089"或其依赖项之一.主机存储中的程序集与 GAC 中的程序集具有不同的签名.(来自 HRESULT 的异常:0x80131050)有关详细信息,请参阅 Microsoft 知识库文章 949080.---> System.IO.FileLoadException: 无法加载文件或程序集System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"或其依赖项之一.主机存储中的程序集与 GAC 中的程序集具有不同的签名.(来自 HRESULT 的异常:0x80131050)有关详细信息,请参阅 Microsoft 知识库文章 949080.

System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050) See Microsoft Knowledge Base article 949080 for more information. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050) See Microsoft Knowledge Base article 949080 for more information.

服务器安装了 .NET 4,我尝试添加的 DLL 来自该服务器.但是 C:Windowsassembly 中显示的 DLL 是 3.0.0 版.

The server has .NET 4 installed and the DLL I have tried to add is from that. However the DLL shown within C:Windowsassembly is version 3.0.0.

我使用 Powershell 更新了 GAC 中的 DLL,但这只会更新位于 C:WindowsMicrosoft.NETassemblyGAC_MSIL 中的 DLL.

I used Powershell to update the DLL in the GAC, but that only updates the DLL located within C:WindowsMicrosoft.NETassemblyGAC_MSIL.

我究竟如何在 C:Windowsassembly(我认为这是 SQL Server 与之比较的那个)获得 GAC 以反映正确的程序集?

How on earth do I get the GAC at C:Windowsassembly (which I assume is the one SQL Server is comparing it to) to reflect the correct assembly?

非常感谢任何帮助.

推荐答案

终于设法让这个工作.不确定这个答案对其他人有多大帮助,但我不得不使用一些来自各种来源的 dll 的混合.

Finally managed to get this working. Not sure how helpful this answer will be to others but I had to use a bit of a mix of dll's from various sources.

基本上,我从本地机器上获取所有 dll 并将它们复制到服务器,然后尝试对本地文件和 .Net 框架内文件的引用组合.

Basically I took all of the dll's from my local machine and copied them to the server and then tried combinations of references to the local files and files within the .Net framework.

最后,我不得不从服务器上的 .Net 引用 1 个 dll,其余的从我的本地机器复制.

In the end I had to reference 1 of the dll's from .Net on the server and the rest of them copied from my local machine.

这让它工作,然后在转移到生产服务器时也工作.不是最简单的解决方案,但我只能建议处于类似情况的任何人尝试使用各种参考组合.

This got it working and also then worked when moved to production server. Not the simplest of solutions but all I can advise anyone in a similar situation is just to try playing around with various combinations of references.

这篇关于GAC 中的 SQLCLR 函数和 System.Runtime.Serialization的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆