Using X86 COM interop with ASP.Net application in Windows x64

It has been almost two months since my last post. It has been very busy here..

I got several good notes with one my previous post, about using x86 COM interop in x64 environment. I also had few questions about using x86 COM interop with ASP.Net application in the 64-bit Windows, such as Windows Server 2003 x64, or Vista x64.

Well, IIS in 64-bit Windows is also 64-bit and uses 64-bit version of .Net Framework. You might deployed your app as pre-compiled binaries or deploying the source, either way, the same error will be thrown in the app is using a 32-bit COM interop. The same error, Retrieving the COM class factory for component with CLSID {GUID HERE} failed due to the following error: 80040154.

If you deployed the ASP.Net source code to the server, ASP.Net does the compilation and it is more challenging to force ASP.Net to compile it as 32-bit application, as the IIS itself is 64-bit.

There is a way to do it, I don't say that this is ideal, but it works.

  1. Configure IIS to run 32-bit ASP.Net application.
    https://technet2.microsoft.com/WindowsServer/en/library/140077b8-8c96-49b0-be17-e47095983c2b1033.mspx?mfr=true
  2. Register ASP.Net 32-bit with IIS.
    Open a command-prompt window at %windows%\Microsoft.Net\Framework\v2.0.50727 and call aspnet_regiis -i.
  3. Enable the 32-bit ASP.Net web service extension from IIS Service Manager (it is not automatically enabled from step 2).

Your ASP.Net application and your 32-bit COM interop now will work. The most ideal situation would be to get the 64-bit version of the COM interop.