
Sure, it's fine for doing proof-of-concepts / quick tests, but it is not a good long-term / production-level option. Setting TRUSTWORTHY ON for msdb is two problems in one:.
Code (assemblies, logins, users, or anything else) shouldn't be given more permissions than necessary.
UNSAFE permission set? Why? For email? The assembly should be EXTERNAL_ACCESS. Deploying to msdb? Maybe it's just me, but I would never deploy code to msdb (and I would only add code to master if it is physically required, such as when marking a proc as either a start up proc or as a system proc). You should use SqlString instead of String for input parameter types (and for return types). HOWEVER, it does not work in SQL Server Express LocalDB :-( SQLCLR not required for sending email in SQL Server Express (I have tested this and it does work). It would be best if you forgot everything you saw in that article and never looked at it again. Well, that article on MSSQLTips is more of a problem than the error that you are getting. I've followed this advice on MSSQLTips article Just to be clear, "clr enabled", and sp_configure in general, are instance-level, not database-level configuration. I've updated target databases: sp_configure 'clr enabled', 1 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. Net SqlClient Data Provider: Msg 10327, Level 14, State 1, Line 1 CREATE ASSEMBLY for assembly 'dbSysmac' failed because assembly 'dbSysmac' is not trusted.
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 I've tried using two different target databases: 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. Send Email from SQL Server Express Using a CLR Stored ProcedureĪnd according to the article I've updated target databases: sp_configure 'clr enabled', 1 Īnd after I've got the error I've followed this advice on MSSQLTips article: (It's a simple function that sends an email.)Īs a reference I used this articles on CodeProject and MSSQLTips:Ĭreate, Run, Debug and Deploy SQL CLR Function with Visual Studio 2013 Database Project I'm trying to (learn) publish a SQLCLR function using Visual Studio 2017.