I'm trying to create my first CLR assembly. I have created a dll in VS and now I am trying to use it in SQL Server.
I try to create assembly with this code:
CREATE ASSEMBLY SQLCLRroy
FROM '...\SqlExternalFunctions\bin\Debug\net5.0\SQLExternalFunctions.dll';
but I get an error
Assembly 'SqlExternalFunctions' references assembly 'system.runtime, version=5.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.', which is not present in the current database.
After trawling the net I try this:
CREATE ASSEMBLY [System.Runtime]
FROM 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Runtime.dll'
which again results in an error
Warning: The Microsoft .NET Framework assembly 'system.runtime, version=5.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.' you are registering is not fully tested in the SQL Server hosted environment and is not supported.
Do I need to stop my .NET code from referencing System.Runtime
somehow? The only package I have is System.Data.SqlClient
My .NET code is very simple:
using System;
using System.Linq;
public static class SqlExternalFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static int myTest(int param )
{
return param;
}
}
Use .Net Framework not .Net Core as the Target Framework in VS