Rick Strahl's Web Log

Wind, waves, code and everything in between...
ASP.NET • C# • HTML5 • JavaScript • AngularJs
Contact   •   Articles   •   Products   •   Support   •   Search
Ad-free experience sponsored by:
ASPOSE - the market leader of .NET and Java APIs for file formats – natively work with DOCX, XLSX, PPT, PDF, images and more

64 Bit Servers, ISAPI and Managed Modules on IIS

So i took a support call from a customer of mine today who ran into problems installing West Wind Web Connection on a 64 bit machine. West Wind Web Connection works through a 32 bit ISAPI extension and sure enough a standard configuration will not allow this ISAPI extension to run. Any attempt to access a 32 bit extension in a 64 bit environment results in a 500 server error and this message

%1 is not a valid Win32 application

Conveniently IE6 (on the server) will hide this message (anything shorter than 512 bytes get overridden by IE's default error message) so you may not actually see the *actual* error message.

You can get around this limitation by forcing IIS to create Application Pools in 32 bit mode by using a Metabase key available on 64 bit machines. You can run the following from a Command Prompt:

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 true

Note that this will affect EVERY IIS application on the Web Server so this is unfortunately an all or nothing option only. This option is widely known and published in Microsoft KB articles and what not.

However, even with that switch set my customer still was unable to run his application. Instead we got:

Service Unavailable

on any page - even static pages in the site.

Service unavailable is familiar - it occurs when IIS itself is running but when an Application Pool is not starting up properly. After getting on the machine and digging through the IIS configuration settings indeed I found that immediately after hitting a page that the Application Pool was being shut down and showing an Unidentified Error.

So my next thought was that it might be an ISAPI Filter causing this issue and a quick look at the ISAPI Filter page indeed showed the ASP.NET 2.0 filter as enabled and 'stopped'. No doubt this is what was causing the problem. The issue is that the ASP.NET filter is now 64 bit in a 32 bit app which causes the failure.

To fix this you can either remove the filter altogether or - probably safer if you use ASP.NET - to re-register ASP.NET for the appropriate framework version (32 bit or 64 bit).

To set up ASP.NET for 32 bit:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_iisreg -i

To set up ASP.NET for 64 bit:

C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727>aspnet_iisreg -i

So in our case I reregistered the app with the 32 bit version and the customer was on his way.

Long Term Solution - .NET Module

A few months ago I wrote a bit about the process of creating a managed module to replace the ISAPI extension for West Wind Web Connection and although it's been on my radar to check out this managed module under 64 bit I hadn't had a chance to try it under 64 bit. So today I finally got the chance to give it a shot. Basically this HttpHandler implementation duplicates the ISAPI functionality and adds a number of cool features that would have been painful to do in C++ code.

I wasn't sure what to expect but I was totally stoked to see that the HttpHandler worked out of the box first try in 64 bit mode! No changes, no failures - and running through a whole suite of request scenarios without any issues. That's pretty impressive given that I didn't spend any time specifically checking for 64 bit issues.

The handler works both with file based messaging mode, WCF and even with COM calling a 32 bit COM server (out of process).

Now I don't think it'd be quite so straight forward with more complex types of applications (that actually deal with a variety of type information) but still I think that this is really quite impressive to be able to have the same code without recompilation run both 64 bit and 32 bit. Of course that's always been one of the promises of .NET but seeing it in action like this really pushes that point home. 

I'll be at DevIntersection in Vegas this fall giving sessions on ASP.NET Core with Angular and Localization. Thinking of coming? Use discount code STRAHL and save a few bucks. If you do be sure to stop by and say hello!

ASP.NET DevIntersection 2017. Rick Strahl Coupon Code

Posted in IIS  Web Connection  

The Voices of Reason


# DotNetSlackers: 64 Bit Servers, ISAPI and Managed Modules on IIS

Anatoly Lubarsky
July 14, 2007

# re: 64 Bit Servers, ISAPI and Managed Modules on IIS

it will be a mistake to use -i switch in this case, IMHO
"-i" registers the specific version to the root and recursively so it breaks all other applications installed or that will be installed in the future.

The right way is to use:
1) aspnet_regiis -ir -enable
2) aspnet_regiis -s

Rick Strahl
July 14, 2007

# re: 64 Bit Servers, ISAPI and Managed Modules on IIS

Thanks Anatoly - good point. Actually - blush - I haven't checked the options for ASP.NET 2.0 in a long time and didn't realize that -i converts all the virtuals. Not really sure why the docs say convert all Application Pools to ASP.NET 2.0 given that on XP/Win2003 IIS version is set on the virtual (hmm... then again I'm running Vista so maybe this message is Vista/Longhorn specific?).

Anyway yes, it looks like you're definitely right to use -ir. I don't think -s is not enough because Filters need to be set at the Web Server not on the virtual (even the root) level.

Barry Holleran
November 29, 2007

# re: 64 Bit Servers, ISAPI and Managed Modules on IIS

Just a minor point and I might be wrong but in the article you state.

aspnet_iisreg -i

should it not be:

aspnet_regiis -i

and then corrected in the later post to:

aspnet_regiis -ir -enable

April 13, 2009

# re: 64 Bit Servers, ISAPI and Managed Modules on IIS

This works great.

Thanks for the solution.

December 30, 2009

# re: 64 Bit Servers, ISAPI and Managed Modules on IIS

Amazing. Thanks for the article. This saved my day today.

February 21, 2010

# re: 64 Bit Servers, ISAPI and Managed Modules on IIS

I am using a shared hosting... what can I do in that case????

Miles B. Freed
March 19, 2012

# re: 64 Bit Servers, ISAPI and Managed Modules on IIS

Try enabling 32 modules on 64 bit server on a strictly ASP environment. All ASP modules that use SQL Server break down. It is either 64bit libraries or nothing.

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2017