February 9, 2014 at 5:12 am
I have followed the basic setup tasks for creating an assembly in C# and using it within a SQL Server UDF but it fails to create and I don't know how to fix it. Is there anyone out there who might know how to help? Or knows someone who knows someone who might be able to help please?
The C# function I'm trying to create just returns a string, so I'm not doing anything complicated.
I'm using SQL Server 2012.
Visual Studio 2012 C#.
Both target the .Net Framework v4.
I've set the sp_configure options to allow CLR.
See below:
select * from sys.dm_clr_properties
Results:
directory:C:\Windows\Microsoft.NET\Framework64\v4.0.30319\
version:v4.0.30319
state:CLR is initialized
However when I run the following SQL it gives me the following error. The part in bold is what confuses me.
CREATE ASSEMBLY UDF_CLRTest
FROM 'C:\Program Files\Microsoft SQL Server\UDF_CLRTest.dll'
WITH PERMISSION_SET = SAFE;
GO
Results:
Msg 6218, Level 16, State 2, Line 1
CREATE ASSEMBLY for assembly 'UDF_CLRTest' failed because assembly 'UDF_CLRTest' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message
[ : UserDefinedFunctions::.ctor][mdToken=0x6000002][offset 0x00000000] Method parent has circular class type parameter constraints.
[ : UserDefinedFunctions::Scalar_CS][mdToken=0x6000001][offset 0x00000000] Method parent has circular class type parameter constraints.
I'm guessing it's a C# error, and not specifically SQL so this might not be the best place to ask, but I thought it'd be worth a try!
February 9, 2014 at 10:55 am
This is typically due to a .Net mismatch.
With other versions it was required to use the .Net2 even though .Net4 was installed.
My 2012 instances return this value
versionv2.0.50727
Do you have multiple versions of .Net installed?
Have you tried a different version of VS?
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
February 10, 2014 at 5:42 am
I thought it was a .Net mismatch too, but I've checked and we have .Net 4 installed on all servers, and as shown in my original post the server query returns version 4.0.30319 so I'm assuming it should all be okay.
I attempted to use Visual Studio 2010, but for the SQL Project types to work Visual Studio 2010 requires a version of SQL Server Data Tools which is no longer being supported by Microsoft. So I scrapped that route.
From: http://blogs.msdn.com/b/ssdt/archive/2014/01/31/ssdt-and-visual-studio-versions.aspx
Visual Studio 2010 - Since the release of Visual Studio 2013, we are no longer offering updates for SSDT on the Visual Studio 2010 shell. To get updates, users will need to move to VS 2012 or VS 2013. Our current plan is to support two shell versions at a time.
February 10, 2014 at 9:41 am
Does the clr involve multiple tables that have PK - FK relationships? Possibly a circular relationship between those constraints?
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply