title: deploy SQL Server Express LocalDB database app with "clr enabled"
body: <p>Cross posted on <a href="https://social.msdn.microsoft.com/Forums/en-US/643eb7b1-b2a4-4bc9-82ca-6e97dba1df5d/localdb-deployment-how-to-enable-clr-on-target-machines?forum=sqldatabaseengine" rel="nofollow">MSDN</a></p>
  
  <p>My app uses the group_concat custom functions on <a href="https://groupconcat.codeplex.com/" rel="nofollow">codeplex</a></p>
  
  <p>I am getting the following error when starting up the app on target machine.</p>
  
  <p><code>Execution of user code in the .NET framework is disabled. Enable clr enabled configuration option.</code></p>
  
  <p>Assuming localdb is installed on target machine, what can I do to enable clr along with install? On my machine, i just opened SSMS and executed the script there. </p>
  
  <p><code>sp_configure 'clr enabled', 1;
  GO
  RECONFIGURE;
  GO</code> </p>
  
  <p>However, SSMS will not be installed on most clients and I am not sure how to make it so the database can use these functions. Any suggestions?</p>
  
  <p><strong>EDIT:</strong>
  I have attempted setting this in c# from the app in two different ways, but both have failed.</p>
  
  <pre><code> public void EnableCLR(string ConnectionString)
      {
          using(SqlConnection con = new SqlConnection(ConnectionString))
          {
              using(SqlCommand cmd = new SqlCommand("sp_configure 'clr enabled', 1", con))
              {
                  cmd.CommandType = CommandType.StoredProcedure;
  
                  con.Open();
  
                  cmd.ExecuteNonQuery(); //Error: Unable to find stored procedure "sp_configure 'clr enabled', 1"
              }
          }
      }
  </code></pre>
  
  <p>Then I tried this</p>
  
  <pre><code> public void EnableCLR(string ConnectionString)
      {
          using(SqlConnection con = new SqlConnection(ConnectionString))
          {
              using(SqlCommand cmd = new SqlCommand("sp_configure", con))
              {
                  cmd.CommandType = CommandType.StoredProcedure;
  
                  con.Open();
  
                  SqlParameter clrParam = new SqlParameter();
  
                  clrParam.ParameterName = "clr enabled";
  
                  clrParam.Value = 1;
  
                  cmd.Parameters.Add(clrParam);
  
                  cmd.ExecuteNonQuery(); //Error: @clr enabled is not a parameter for procedure sp_configure.
              }
          }
      }
  </code></pre>