none
CREATE ASSEMBLY for assembly <Assembly Name> failed because the assembly is built for an unsupported version of the Common Language Runtime.

    Question

  • Not sure if this is an SQL or C# question, but here it goes:  I am trying to create my first CLR assembly for SQL using C#.  I found several examples online, and am following them.  However, when I try to load my assembly into the SQL Server, I receive the aforementioned error.  I've googled the heck out of it an am coming up with nothing.  Anyone have an idea that can point me in the right direction?
    • Moved by CoolDadTxMVP Friday, July 23, 2010 1:25 PM SQL related (From:Visual C# General)
    Thursday, July 22, 2010 10:16 PM

Answers

  • SQL Server 2008 uses .NET Framework 3.5 SP1 (and, really, the base portion of the framework is just 2.0 with updates, 3.0 and 3.5 just update the 2.0 base and add some new assemblies). If changing the VS2010 to 3.5 didn't do it, I'd try starting out with an entire new project and set the target to 3.5 at project creation time. Unless you're using some odd referenced assemblies that are version 1.1 or 4.0, this should work (I've been using VS2010 with 3.5 targets for SQLCLR for quite a while without incident).

    Hope this helps, Cheers, Bob Beauchemin, SQLskills

    • Marked as answer by KJian_ Friday, August 06, 2010 11:46 AM
    Friday, July 23, 2010 9:48 PM
    Moderator

All replies

  • Hi.

    I don't know exact solution. But first that can be suggested: your assembly is built with version newer than SQL Server. Than I will go to to assembly's project properties and try to set more older version of .NET Framework (Application->Target Framework combobox).
    Friday, July 23, 2010 9:49 AM
  • I thought about that,  but I am using VS 2010 and SQL 2008, so the latest of both.  I did have my VS2010 project set to use .NET 4, so I converted it to 3.5 but had the same issue.   I do know that .NET 2 - 4 clients (and everything in the middle) are installed on the SQL I am trying to test with.  Is there some limitation with CLR where it can only support version 2 or lower?
    Friday, July 23, 2010 1:15 PM
  • SQL Server 2008 uses .NET Framework 3.5 SP1 (and, really, the base portion of the framework is just 2.0 with updates, 3.0 and 3.5 just update the 2.0 base and add some new assemblies). If changing the VS2010 to 3.5 didn't do it, I'd try starting out with an entire new project and set the target to 3.5 at project creation time. Unless you're using some odd referenced assemblies that are version 1.1 or 4.0, this should work (I've been using VS2010 with 3.5 targets for SQLCLR for quite a while without incident).

    Hope this helps, Cheers, Bob Beauchemin, SQLskills

    • Marked as answer by KJian_ Friday, August 06, 2010 11:46 AM
    Friday, July 23, 2010 9:48 PM
    Moderator