System.Security.HostProtectionException when Executing User Defined Function on SQL Server
CLR assemblies have trust levels.
This one requires UNSAFE permissions because of the rights required to use "MayLeakOnAbort"
Either change the CLR to something safer, or re-add the assembly with UNSAFE rights. The word "UNSAFE" is exactly that of course...
In my case I found that changing a HashSet to a List in my CLR code made this issue go away. Have no idea why that is. Hopefully that might help someone.