I need to use SQLCLR to make a stored procedure that uses stuff in .NET 3.5. If I don’t use PERMISSION_SET = UNSAFE I can’t do it, it will just die and give me this error:
Deploy error SQL01268: .Net SqlClient
Data Provider: Msg 6503, Level 16, State 12, Line 1
Assembly ‘system.core, version=3.5.0.0, culture=neutral, publickeytoken=b77a5c561934e089.’ was not found in the SQL catalog.
An error occurred while the batch was being executed.
So I found this article:
And the last line says this:
“Now the DBAs won’t definitely let me use this, but it was fun to build it.”
I am not sure if he was referring to the permissions being set to “unsafe”.
So, can some huge gaping hole happen if you do this?
There are three different permission_set options which restrict what the assembly can do
SAFE– Restricts the assembly to managed codeEXTERNAL_ACCESS– allows access to files, network resources, etc..UNSAFE– Unrestricted access – including the execution of non-managed codeMSDN docs give the following guidance
If your assembly only uses features of .NET 3.5, i don’t see why it would need
UNSAFEaccess.It’s possible you are using one of the types or members disallowed from the System.Core library. Microsoft has a list of these. Disallowed Types and Members in System.Core.dll
There is some more info here. Host Protection Attributes and CLR Integration Programming