title: Class not registered error from PHP
body: <p>We've created a C# class library assembly and made it COM visible to be able to call its methods from PHP. This used to work fine, but now we wanted to install it on a Windows Server 2008 server and we keep walking into the error "Class not registered".</p>
  
  <p>To rule out any dependency problems I made a tiny little test class library in C#. The class library is built for Any CPU and it is COM visible (also set COMVisible to true in AssemblyInfo.cs). The test class library only contains one class with one method. The class is called TestLib and the namespace is also called TestLib. The method is called Test and only returns a string.</p>
  
  <p>What we have done is the following:
  - built the TestLib.dll
  - copied it to the Windows Server 2008 machine
  - registered the dll with: regasm /codebase TestLib.dll
  - the regasm tool returns a success message
  - in PHP we simply try to create a new COM instance:</p>
  
  <pre><code>try
  {
     $test = new COM("TestLib.TestLib");
  }
  catch (Exception $e)
  {
     die($e-&gt;getMessage());
  }
  </code></pre>
  
  <ul>
  <li>when we call this test script from either the browser or the commandline (php -f test.php) we get the error "Class not registered" in both cases</li>
  </ul>
  
  <p>I also tried adding TestLib to the GAC by using gacutil -i, but to no avail; still the class not registered error.</p>
  
  <p>Then I tried compiling the testlibrary with .NET 2.0 instead of 4.0 as the target framework, same result. The .NET framework 4.0 is installed on the server by the way.</p>
  
  <p>Any ideas?</p>