You have to register unsupported libraries before you can use them.
-- You will have to use the Runtime Serialization from .NET v3
ALTER DATABASE [<<Database Name>>] SET TRUSTWORTHY ON;
CREATE ASSEMBLY AnyName_You_Want
FROM
--'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Runtime.Serialization.dll'
'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\System.Runtime.Serialization.dll'
WITH PERMISSION_SET = UNSAFE;
Excerpt:
Unsupported libraries can still be called from your managed stored
procedures, triggers, user-defined functions, user-defined types, and
user-defined aggregates. The unsupported library must first be
registered in the SQL Server database, using the CREATE ASSEMBLY
statement, before it can be used in your code. Any unsupported library
that is registered and run on the server should be reviewed and tested
for security and reliability.
For example, the System.DirectoryServices namespace is not supported.
You must register the System.DirectoryServices.dll assembly with
UNSAFE permissions before you can call it from your code. The UNSAFE
permission is necessary because classes in the
System.DirectoryServices namespace do not meet the requirements for
SAFE or EXTERNAL_ACCESS. For more information, see CLR Integration
Programming Model Restrictions and CLR Integration Code Access
Security.
CLR integration in SQL Server only supports a subset of .NET Framework Libraries. The libraries/namespaces supported by CLR integration in SQL Server are:
- CustomMarshalers
- Microsoft.VisualBasic
- Microsoft.VisualC
- mscorlib
- System
- System.Configuration
- System.Data
- System.Data.OracleClient
- System.Data.SqlXml
- System.Deployment
- System.Security
- System.Transactions
- System.Web.Services
- System.Xml
- System.Core.dll
- System.Xml.Linq.dll