Search code examples
sqlclr

Unable to Deploy SQLCLR Project


My first SQLCLR project is resisting all attempts to deploy...

I get the error

The following error might appear if you deploy a SQL CLR project that was built for a version of the .NET Framework that is incompatible with the target instance of SQL Server: "Deploy error SQL01268: CREATE ASSEMBLY for assembly failed because assembly failed verification". To resolve this issue, open the properties for the project, and change the .NET Framework version.

C:...\SqlClr.dll : Deploy error : Could not create a type for parameter MyModel.Customer customer

The command

select * from sys.dm_clr_properties

returns

directory C:\Windows\Microsoft.NET\Framework64\v2.0.50727\

version v2.0.50727

state CLR is initialized

The Target framework for the project is .NET Framework 2.0

The object referenced in the error message MyModel.Customer is included in the SqlClr project via a Link (Add Existing Item / Add as Link) from another project that is using .NET Framework 4.0, but my understanding is the other project's .NET version should have no bearing.

What might I be missing?


Solution

  • If you are referencing an assembly that is dependent upon .NET 4.0, you're likely in for trouble. My understanding is that SQLCLR assemblies must be based on .NET versions 2.0 through 3.5, because versions 2.x and later prior to 4.0 are really just extensions based on 2.0. That tends to coincide with some information I read recently about an explicit decision for the SQLCLR not to support Framework 4.0.