Running 32 bit assemblies on 64 bit IIS


The Situation


Consider this scenario:

  • IT moves your servers to Windows 2008 and, while doing so, also decides to go 64 bit.
  • You change your solution to compile against 64 bit .Net and recompile your app.
  • You publish your ASP.Net applications onto the new machine and are greeted with an error message along the lines of “could not load dll, wrong format”.
  • You investigate and quickly identify that one of the external assemblies you are using in your application is compiled against the 32 bit .NET framework.
  • You spend hours trying to track down a 64 bit version for your assembly and realize there is none for your specific version of the DLL … and no source code to compile it yourself. (I am looking at you Oracle and ODN.Net)


Now you're stuck. You can't create a 64 bit version of your application, pressure is mounting to get your app functional again and any attempts at obtaining support / a new assembly from the third party vendor die in the callcenter.

The Solution

One, fast, but not pretty solution to this dilemma is to modify IIS to run in 32 bit mode. Unfortunately there's a number of steps involved in making this work and I haven't been able to find a MSDN page that summarizes them all - hence this page.

Necessary Steps:

  • Add the 32bit ASP.NET ASAPI plugin to IIS and set it to higher priority than the 64 bit counterpart.

* Enable 32bit Appools on your 64bit machine via the admin scripts:

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1
  • Install the 32bit ASP.Net framework which is not installed by default on 64 bit environments:
%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i 

Note: In regards to some functionality, even this solution would not help you - e.g. if you're using 32bit ODBC driver features such as ODBC access to read or write Excel files, you're out of luck. Those drivers won't work with 64bit and Microsoft has stated that they will not make the move to 64 bit.


Drawbacks

  • You're back to 32 bit - with it's all its limitations (memory, etc.).
  • IIS only supports 32-bit worker processes in Worker Process Isolation mode on 64-bit Windows.


References