title: oa_spcreate returns Class Not Registered error on a .net Assembly
body: <p>For the reason beyond my control I am forced to use <code>oa_spcreate</code> functionality from within SQL Server 2008 R2 64bit. The old VB6 DLLs (again out of my control) are not supported by 64bit version (32bit consideration is on the way). </p>
  
  <p>I have tried to create a .NET wrapper for some of the functions on the old DLLs. Followed bits and pieces a knocked it together. </p>
  
  <p>Code sample:</p>
  
  <pre class="lang-cs prettyprint-override"><code>namespace Some32bitWrapper
  {
      [ClassInterface(ClassInterfaceType.None)]
      public class Dissues32iClass : iDissues32iClass
      {
          public Dissues32iClass()
          {
          }
  
          //Instantiate iclass and execute InsertLocDetailLinesOnServer
          public Object InsertLocDetailLinesOnServer(String ConnectString, String DetailsString, int User)
          {
              try
              {
                  DIssues32.Iclass _iclass = new Iclass();
                  Object _return = _iclass.InsertLocDetailLinesOnServer(ConnectString, DetailsString, User);
  
                  return _return;
              }
              catch (Exception er)
              {
                  return er.Message;
              }
          }
      }
  
      public interface iDissues32iClass
      {
          Object InsertLocDetailLinesOnServer(String ConnectString, String DetailsString, int User); 
      }
  }
  </code></pre>
  
  <p>Complied, registered with tlb regasm and tlb, gacutil-ed it. All seems honky-dory. As soon as I try run it from within SQL stored procedure using <code>sp_oacreate</code> get "Class not registered" error.</p>
  
  <p>Stored Proc code:</p>
  
  <pre class="lang-sql prettyprint-override"><code>ALTER PROCEDURE [dbo].[DIME_InsertLocDetailLinesOnServer]
  @tConnectionString varchar(255),
  @SysUser int,
  @tDetailsString text
  AS
  declare @hr int
  declare @Object int
  declare @Return int
  declare @Output varchar(255)
  
  --HKEY_CLASSES_ROOT\TypeLib\{492BF323-0691-4F62-9171-3F75F4DF2753}
  exec @hr= sp_OACreate 'Some32bitWrapper.Dissues32iClass',@object out,5
  
  IF @hr &lt;&gt; 0
  BEGIN
      EXEC sp_Getoaerrorinfo @object, @hr,@output out
      select @output,@hr
      RETURN -2
  END
  else
   return 'registered'
   begin
      exec @hr = sp_OAMethod @object,'InsertLocDetailLinesOnServer',NULL, @ConnectString = @tConnectionString,
                 @DetailsString = @tDetailsString,@User = @Sysuser
  
      IF @hr &lt;&gt; 0
      BEGIN
          EXEC sp_Getoaerrorinfo @object, @hr,@output out
              select @output
          RETURN -3
      END
  
      exec @hr= sp_OADestroy @object out
  
      print @return
   end
  </code></pre>
  
  <p>Not a lot of information on it, except "don't use don't use types". At this time do not have a choice. Anybody can help?</p>
  
  <p>P.S.: I ran all of the required reconfigure options on SQL Server and permission grants.</p>