You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create assembly [System.EnterpriseServices]
from'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.EnterpriseServices.dll'
with permission_set = unsafe
create assembly TestClr from'TestClr.dll' with permission_set = unsafe
scalar-valued UDF works as expected:
createfunctionScalarTest() returns nvarchar(max) as external name TestClr.SqlClr.ScalarTest
selectdbo.ScalarTest()
> testing
table-valued UDF throws:
createfunctionTableTest() returns table (test nvarchar(max)) as external name TestClr.SqlClr.TableTest
> The Init method for a CLR table-valued function must be annotated with SqlFunctionAttribute.
Further technical details
Microsoft.SqlServer.Server version: 1.0.0
.NET target: netstandard2.0
SQL Server version: SQL Server 2022
Operating system: Windows Server 2022
The text was updated successfully, but these errors were encountered:
Hi @gfody, I'm digging into this, but some additional context would be helpful. You mentioned that this issue popped up "after porting" to netstandard2.0. Does this mean you were previously targeting .net framework directly? If so, which version of .net framework were you targeting and did your examples work at that time?
Can you also help me understand your motivation for targeting .net standard as opposed to .net framework?
yeah our SQLCLR assemblies currently target net481. the motivation for targeting netstandard2.0 was mostly just to see if it was possible. for context we recently started supporting macOS as a development environment which entailed splitting the SQLCLR assemblies into separate projects (see gfody/SqlClrTest). I wanted to see if it was possible to just deploy the netstandard2.0 build if so I'd not bother dual targeting.
btw I think it's likely ILRepack is messing up the SqlFunctionAttribute somehow but I couldn't get the assembly deployed w/o it (hit issues similar to what's described in #2838)
Describe the bug
After porting a SQLCLR assembly to netstandard2.0, scalar-valued UDFs work but table-valued UDFs do not.
To reproduce
create a test SQLCLR assembly targeting netstandard2.0 using the Microsoft.SqlServer.Server package:
class w/a scalar-valued udf and a table-valued udf to test:
deploy the assembly:
scalar-valued UDF works as expected:
table-valued UDF throws:
Further technical details
Microsoft.SqlServer.Server version: 1.0.0
.NET target: netstandard2.0
SQL Server version: SQL Server 2022
Operating system: Windows Server 2022
The text was updated successfully, but these errors were encountered: