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

查看:202
本文介绍了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,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b77a5c561934e089'或其依赖项之一.主机存储区中的程序集与GAC中的程序集具有不同的签名. (来自HRESULT的异常:0x80131050)有关更多信息,请参见Microsoft知识库文章949080. ---> System.IO.FileLoadException:无法加载文件或程序集'System.Runtime.Serialization,版本= 3.0.0.0,区域性=中性,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:\ Windows \ assembly中显示的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:\Windows\assembly is version 3.0.0.

我使用Powershell更新了GAC中的DLL,但这仅更新了C:\ Windows \ Microsoft.NET \ assembly \ GAC_MSIL中的DLL.

I used Powershell to update the DLL in the GAC, but that only updates the DLL located within C:\Windows\Microsoft.NET\assembly\GAC_MSIL.

究竟如何在GA C:\ Windows \ assembly(我假设这是SQL Server与之进行比较的地方)处获得GAC以反映正确的程序集?

How on earth do I get the GAC at C:\Windows\assembly (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天全站免登陆