Search code examples
c#sql-serverclr

CLR Trigger Deploy Error


I am attempting to deploy a CLR trigger that links to an external .dll file that contains a library I wrote. Right now I just want to be able to test the code on a local database. I have set the local database to Trustworthy = True and external assembly access to my username. I also added a reference to the external library I am trying to use, but when I call the function I get this error

Severity    Code    Description Project File    Line    Suppression State
Error       SQL72014: .Net SqlClient Data Provider: Msg 6503, Level 16, 
State 12, Line 1 Assembly 'googlecalendersync, version=1.0.0.0, 
culture=neutral, publickeytoken=fab9d21c96557bef.' was not found in the SQL 
catalog.    Test3   C:\Users\dwd002\Documents\Visual Studio 
2015\Projects\Test3\Test3\bin\Debug\Test3.sql   52  

Any help would be much apreciated. I know right now that it is unsafe the way I am doing it, right now it's just a proof of concept. Is there something I am doing wrong when building the library .dll?


Solution

  • I think you are using a 3rd party dll in your clr project

    Firstly you need create Assembly From your third party dll

    use master
    GO
    CREATE ASYMMETRIC KEY ClrGoogleCalender
    FROM EXECUTABLE FILE='<Your 3rd party dll path>'
    CREATE LOGIN CLRGoogleCalenderLOGIN FROM ASYMMETRIC KEY ClrGoogleCalender
    GRANT UNSAFE ASSEMBLY TO ClrGoogleCalenderLOGIN
    GO
    

    And then Uplaod your third party dll to sql server catalog

    [1]: https://i.sstatic.net/sBhQZ.png