Error publishing SQLCLR C# Function using Visual Studio 2017
3
votes
1
answer
2233
views
I'm trying to (learn) publish a SQLCLR function using Visual Studio 2017. (It's a simple function that sends an email.)
As a reference I used this articles on CodeProject and MSSQLTips :
Create, Run, Debug and Deploy SQL CLR Function with Visual Studio 2013 Database Project
Send Email from SQL Server Express Using a CLR Stored Procedure
On project properties->SQLCLR I've set:
Permission level : UNSAFE
And according to the article I've updated target databases:
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO
And after I've got the error I've followed this advice on MSSQLTips article:
>If you get error messages when trying to compile the code you may need to alter the database using the following command and then try again to create the assembly and the stored procedure.
ALTER DATABASE msdb SET trustworthy ON
I've tried using two different target databases:
- SQL-Server 2017 LocalDB
- SQL-Server 2017 Express
I can build the project without errors, but when I publish the project I receive one error when it executes the next command:
CREATE ASSEMBLY [dbSysmac]
AUTHORIZATION [dbo]
FROM 0x5F8A900003000000...
WITH PERMISSION_SET = UNSAFE;
>(47,1): SQL72014: .Net SqlClient Data Provider: Msg 10327, Level 14, State 1, Line 1 CREATE ASSEMBLY for assembly 'dbSysmac' failed because assembly 'dbSysmac' is not trusted. The assembly is trusted when either of the following is true: the assembly is signed with a certificate or an asymmetric key that has a corresponding login with UNSAFE ASSEMBLY permission, or the assembly is trusted using sp_add_trusted_assembly.
What I'm doing wrong?
Asked by McNets
(23999 rep)
Jan 20, 2019, 10:18 PM
Last activity: Jan 21, 2019, 08:17 PM
Last activity: Jan 21, 2019, 08:17 PM