title: InteropServices COMException when executing a .net app from a web CGI script on Windows Server 2003
body: <p><em>Disclaimer:  I'm completely clueless about .net and COM.</em></p>
  
  <p>I have a vendor's application that appears to be written in .net and I'm trying to wrap it with a web form (a cgi-bin Perl script) so I can eventually launch this vendor's app from a separate computer.  I'm on a Windows Server 2003 R2 SE SP1 system and I'm using Apache 2.2 for the web server and ActivePerl 5.10.0.1004 for the cgi script.  My cgi script calls the vendor's app that resides on the same machine using the Perl backtick operator.  </p>
  
  <pre><code>...
  $result = "Result: " . `$vendorsPath/$vendorsExecutable $arg1 $arg2`;
  ...
  </code></pre>
  
  <p>Right now I'm just running IE web browser locally on the server machine and accessing "<a href="http://localhost/cgi-bin/myPerlScript.pl" rel="nofollow noreferrer">http://localhost/cgi-bin/myPerlScript.pl</a>".  The vendor's app fails and logs a debug message that includes the following stack trace (I changed a couple names so as to not give away the vendor's identity):</p>
  
  <pre><code>...
  System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; System.Runtime.InteropServices.COMException (0x80043A1D): 0x80040154 - Class not registered
     --- End of inner exception stack trace ---
     at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
     at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
     at VendorsTool.Engine.Core.VendorsEngine.LoadVendorsServices(String fileName, String&amp; projectCommPath)
  ...
  </code></pre>
  
  <p>When I run the vendors app from the Windows command line on the server machine with the exact same arguments that the cgi script is passing it runs just fine, so there's something about invoking their app via the web script that is causing a problem.  This problem is likely security related because the whole thing runs just fine on a Windows XP Pro machine (both command line and web invocation).  I actually developed my web script there and got it completely working there before I tried moving it to the Windows Server 2003 machine.  So what's different about the Windows Server 2003 machine that would keep the vendor's .net app from being executed successfully by a web cgi script?  </p>
  
  <p>Can I fix this problem somehow to make it work on my server or will the vendor have to make a change to their .net app and ship out a new version?  I'm probably the only person in the world who is trying to execute this vendor's app from a separate program, so I hate to bother the vendor with the issue if there's a workaround that I can implement myself here on my server machine.  Plus, I'm in kind of a hurry and I don't want to wait 4 or 6 months for the vendor to put in a fix and deploy a new version.  </p>
  
  <p>Thanks for any advise you can give.</p>