I am developping an SQL Server Database Project in Visual Studio which is in fact a User Defined Function. In this project, I included Json.NET as a reference (using NuGet).
I managed to publish (and make work) my assembly and the UDF to my SQL Server instance by first turning the database TRUSTWORTHY ON
(since my project is UNSAFE) and then running this:
CREATE ASSEMBLY [System.Runtime.Serialization]
FROM 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.Serialization.dll'
WITH PERMISSION_SET = UNSAFE;
Which turns out to be an assembly Json.NET depends on (if I don't do it, I get an error)
Meanwhile I read about how bad turning TRUSTWORTHY ON can be and I tried to go the asymmetric key way to avoid turning it on.
Before even signing my own assembly, I know I will have to create a key for System.Runtime.Serialization
since my project depends on Json.Net which in turn depends on it, but when I run it, I get this:
USE [master];
GO
CREATE ASYMMETRIC KEY [SystemRuntimeSerializationKey]
AUTHORIZATION [dbo]
FROM EXECUTABLE FILE = 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.Serialization.dll';
GO
Msg 15468, Level 16, State 5, Line 3
An error occurred during the generation of the asymmetric key.
Which does not help me much.
So is it possible to generate such a key for .NET framework assemblies, or does it exist a workaround other that turning TRUSTWORTHY ON ?