title: Creating a UserDefined CLR function in .Net
body: <p>i want to create a CLR function, i created a normal class library file and coded as below, i dont want to use SqlServerProject, as i cannot find some classes there.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using Microsoft.SqlServer.Server;
  using System.Data.SqlTypes;
  using Microsoft.SqlServer.Types;
  
      namespace ClassLibrary1
      {
          public partial class Class1
          {
              [Microsoft.SqlServer.Server.SqlFunction]
              public static SqlString GetPassword(SqlString Value)
              {
                  return Value;
              }
          }
      }
  </code></pre>
  
  <p>i compiled the code and created assembly from sqlserver like this</p>
  
  <pre><code>CREATE ASSEMBLY ASSEM
  authorization dbo
  FROM 'E:\NBM Sites\tvt.stage.asentechdev1.com\ClassLibrary1.dll' WITH PERMISSION_SET = SAFE;
  </code></pre>
  
  <p>and created a function as below</p>
  
  <pre><code>CREATE FUNCTION SampleFunc
  (   
      @value nvarchar(max)
  )
  RETURNS nvarchar(max) with execute as caller
  AS
      External Name ASSEM.Class1.GetPassword
  GO
  </code></pre>
  
  <p>but the above create function threw an error saying.</p>
  
  <pre><code>Could not find Type 'Class1' in assembly 'ClassLibrary1'.
  </code></pre>
  
  <p>i dont understand, why the class1 is not recognised, as also i have made it public.
  Please any one help me for it.</p>