newtonsoft.json parser in a C# CLR for SQL Server 2008 R2 - How to deploy?

℡╲_俬逩灬. 提交于 2019-12-21 17:50:50

问题


I have created a CLR which uses the newtonsoft json parser.

I need to deploy the CLR. I have created an assembly for the parser dependency:

CREATE ASSEMBLY [Newtonsoft.Json] FROM 'C:\share\Release\Newtonsoft.Json.dll' WITH PERMISSION_SET = UNSAFE

The above statement throws an error:

`Assembly 'Newtonsoft.Json' references assembly 'system.runtime.serialization, version=3.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(failed to retrieve text for this error. Reason: 15105)).` Please load the referenced assembly into the current database and retry your request.

I am using version 7.xx of the parser. I am targeting .NET 3.5

What is the proper procedure for deploying the CLR to sql server 2008 r2?


回答1:


Sorry, I had made an incorrect assumption in my comment. Only certain libraries in the GAC are supported for SQL CLR by default.

In order to use that library, you'll need to explicitly add it as well.

CREATE ASSEMBLY System_Runtime_Serialization FROM 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\System.Runtime.Serialization.dll'
WITH PERMISSION_SET = UNSAFE
GO

If you are using 64-bit SQL Server, make sure you use Framework64 instead of Framework.



来源:https://stackoverflow.com/questions/33794855/newtonsoft-json-parser-in-a-c-sharp-clr-for-sql-server-2008-r2-how-to-deploy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!