Tuesday 29 September 2009

Execution of user code in the .NET Framework is disabled

I was testing our new SQL Server 2008 enterprise cluster today and managed to get the following SqlException running a C# application:
"Execution of user code in the .NET Framework is disabled. Enable "clr enabled" configuration option.
The statement has been terminated."


The solution is to run the following:
EXEC sp_configure 'show advanced options', '1' ;
go
RECONFIGURE ;
go
EXEC sp_configure 'clr enabled', '1'
go
RECONFIGURE ;
-- Turn advanced options back off
-- EXEC sp_configure 'show advanced options' , '0';
GO