I have sql server 2008r2. According to my internet research it supports .net framework 4.0. I tried to install my assembly with sql clr functions and receved an error.
CREATE ASSEMBLY for assembly 'MyAssembly' failed because the assembly is built for an unsupported version of the Common Language Runtime.
Query
select * from sys.dm_clr_properties
Gives result:
directory C:\Windows\Microsoft.NET\Framework64\v2.0.50727\
version v2.0.50727
CLR is initialized
I check C:\Windows\Microsoft.NET\Framework64\ to be sure and found v4.0.30319 folder where. So, .net v4.0 is installed.
So, I need to change CLR version that used for sql. I tried
sp_configure 'clr enabled', 0;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO
It did not help. I tried to add sqlservr.exe.config with content
<configuration>
<startup>
<requiredRuntime version="v4.0"/>
</startup>
</configuration>
to C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn folder and restart sql server. It didn't help as well.
I know about option with creating registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\OnlyUseLatestCLR and setting it to 1. It can broke other solutions, so I affraid of using it on production.
Is where any suggestions how to convince sql server to use clr v4.0?
Windows Server 2008/2008 R2 and SQL Server 2008/2008 R2 have both met their end-of-life dates: July 9, 2019 for SQL Server 2008/2008 R2 and January 14, 2020 for Windows Server 2008/2008. If you're still running any of those machines, you're doing so at your own risk—especially in this age of cyberattacks.
SQL Server 2008 R2 is not supported on Windows 10 or Windows Server 2016.
CLR integration allows us to use user assemblies when coding a database solution in SQL Server. It was meant to be both an improvement and a future replacement to extended stored procedures, which are a special kind of stored procedure written using C language and compiled in machine code as a dll library.
You can't. In an article posted by Doug Holland in 2010 it is explained that older versions of SQL Server (up to and including 2008 R2) use the LockClrVersion call to restrict the .NET version that can be loaded to the latest 2.0 version.
To use .NET 4.0 you will have to use SQL Server 2012 and above
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With