Contact   •   Products   •   Search

Rick Strahl's Web Log

Wind, waves, code and everything in between...
ASP.NET • C# • HTML5 • JavaScript • AngularJs

Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll


I’ve been having a few problems with my Windows 7 install and trying to get IIS applications to run properly in 64 bit. After installing IIS and creating virtual directories for several of my applications and firing them up I was left with the following error message from IIS:

Calling LoadLibraryEx on ISAPI filter “c:\windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll” failed

IisIsapiFilterError

This is on Windows 7 64 bit and running on an ASP.NET 4.0 Application configured for running 64 bit (32 bit disabled). It’s also on what is essentially a brand new installation of IIS and Windows 7. So it failed right out of the box.

The problem here is that IIS is trying to loading this ISAPI filter from the 32 bit folder – it should be loading from Framework64 folder note the Framework folder. The aspnet_filter.dll component is a small Win32 ISAPI filter used to back up the cookieless session state for ASP.NET on IIS 7 applications. It’s not terribly important because of this focus, but it’s a default loaded component.

After a lot of fiddling I ended up with two solutions (with the help and support of some Twitter folks):

  • Switch IIS to run in 32 bit mode
  • Fix the filter listing in ApplicationHost.config

Switching IIS to allow 32 Bit Code

This is a quick fix for the problem above which enables 32 bit code in the Application Pool. The problem above is that IIS is trying to load a 32 bit ISAPI filter and enabling 32 bit code gets you around this problem. To configure your Application Pool, open the Application Pool in IIS Manager bring up Advanced Options and Enable 32 Bit Applications:

Enable32BitMode

And voila the error message above goes away.

Fix Filters

Enabling 32 bit code is a quick fix solution to this problem, but not an ideal one. If you’re running a pure .NET application that doesn’t need to do COM or pInvoke Interop with 32 bit apps there’s usually no need for enabling 32 bit code in an Application Pool as you can run in native 64 bit code. So trying to get 64 bit working natively is a pretty key feature in my opinion :-)

So what’s the problem – why is IIS trying to load a 32 bit DLL in a 64 bit install, especially if the application pool is configured to not allow 32 bit code at all? The problem lies in the server configuration and the fact that 32 bit and 64 bit configuration settings exist side by side in IIS. If I open my Default Web Site (or any other root Web Site) and go to the ISAPI filter list here’s what I see:

ISAPIFilters

Notice that there are 3 entries for ASP.NET 4.0 in this list. Only two of them however are specifically scoped to the specifically to 32 bit or 64 bit. As you can see the 64 bit filter correctly points at the Framework64 folder to load the dll, while both the 32 bit and the ‘generic’ entry point at the plain Framework 32 bit folder.

Aha! Hence lies our problem.

You can edit ApplicationHost.config manually, but I ran into the nasty issue of not being able to easily edit that file with the 32 bit editor (who ever thought that was a good idea???? WTF). You have to open ApplicationHost.Config in a 64 bit native text editor – which Visual Studio is not. Or my favorite editor: EditPad Pro. Since I don’t have a native 64 bit editor handy Notepad was my only choice.

Or as an alternative you can use the IIS 7.5 Configuration Editor which lets you interactively browse and edit most ApplicationHost settings. You can drill into the configuration hierarchy visually to find your keys and edit attributes and sub values in property editor type interface. I had no idea this tool existed prior to today and it’s pretty cool as it gives you some visual clues to options available – especially in absence of an Intellisense scheme you’d get in Visual Studio (which doesn’t work).

To use the Configuration Editor go the Web Site root and use the Configuration Editor option in the Management Group. Drill into System.webServer/isapiFilters and then click on the Collection’s … button on the right. You should now see a display like this:

ConfigurationEditor

which shows all the same attributes you’d see in ApplicationHost.config (cool!). These entries correspond to these raw ApplicationHost.config entries:

<filter name="ASP.Net_4.0" path="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll" enableCache="true" preCondition="runtimeVersionv4.0" />
<filter name="ASP.Net_4.0_64bit" path="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_filter.dll" enableCache="true" preCondition="runtimeVersionv4.0,bitness64" />
<filter name="ASP.Net_4.0_32bit" path="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll" enableCache="true" preCondition="runtimeVersionv4.0,bitness32" />

The key attribute we’re concerned with here is the preCondition and the bitness subvalue. Notice that the ‘generic’ version – which comes first in the filter list – has no bitness assigned to it, so it defaults to 32 bit and the 32 bit dll path. And this is where our problem comes from.

The simple solution to fix the startup problem is to remove the generic entry from this list here or in the filters list shown earlier and leave only the bitness specific versions active.

The preCondition attribute acts as a filter and as you can see here it filters the list by runtime version and bitness value. This is something to keep an eye out in general – if a bitness values are missing it’s easy to run into conflicts like this with any settings that are global and especially those that load modules and handlers and other executable code. On 64 bit systems it’s a good idea to explicitly set the bitness of all entries or remove the non-specific versions and add bit specific entries.

So how did this get misconfigured?

I installed IIS before everything else was installed on this machine and then went ahead and installed Visual Studio. I suspect the Visual Studio install munged this up as I never saw a similar problem on my live server where everything just worked right out of the box.

In searching about this problem a lot of solutions pointed at using aspnet_regiis –r from the Framework64 directory, but that did not fix this extra entry in the filters list – it adds the required 32 bit and 64 bit entries, but it doesn’t remove the errand un-bitness set entry.

Hopefully this post will help out anybody who runs into a similar situation without having to trouble shoot all the way down into the configuration settings and noticing the bitness settings. It’s a good lesson learned for me – this is my first desktop install of a 64 bit OS and things like this are what I was reluctant to find. Now that I ran into this I have a good idea what to look for with 32/64 bit misconfigurations in IIS at least.

Make Donation
Posted in IIS7   ASP.NET  


Feedback for this Post

 
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Peter April 07, 2011 @ 8:41pm
Running applications in 64 bit I noticed a pretty significant memory increase (more than double) as opposed to running the same application in 32 bit. This was for a pure .net app, no com or interop. Not sure why the huge memory increase (win server 2008, not r2), but for me, given that I couldn't see any difference between 64 and 32 bit, it just wasn't worth it; kept it as 32 bit only.
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Rick Strahl April 08, 2011 @ 2:56am
@Peter - 64 bit apps will use more memory because well they use 64 bit pointers which take up more space. It shouldn't be double though - it really depends on the application. The more memory pointers the more the memory usage. As to performance somethings will be faster on 64 bit especially tight computing operations, looping etc where the JIT can take advantage of the extra registers available to cache data internally staying in the processor.

On the other hand 32 bit apps are limited to 4 gigs of memory, 64 bit can use much more although a lot of non-server machines like my laptop are physically limited to 8 gigs.

Overall I agree though - I ran some non-scientific stress tests on a few applications here and I saw maybe a 5% performance variance back and forth with 64 winning out more times than 32 bit. For these 5 apps I tested memory usage for 64 bit tended to be around 30% more for 64 bit in each case.

64 bit is no panacea, at least not until applications and compilers get fully optimized to take advantage of 64 bit registers/opcodes. In the meantime I don't think this is a make or break deal, although I think it's a good idea to get apps ready for 64 bit.

The current stack of OS's is supposed to be the last one that comes in 32 bit flavors. Windows Next is supposed to be all 64 bit...
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Florin September 13, 2011 @ 10:52pm
THANKS A LOT, MATE!

I've spent quite a lot of time trying to figure out what was going wrong, generating the error 500... I had almost lost hope! You're a life saver!

Too bad your post doesn't pop up higher in the Google results - all I could find was the aspnet_regiis -r solution, which solved nothing.

^:)^
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Jon September 29, 2011 @ 6:48am
Only your blog was able to help me out after 2-3 hours of searching on google this worked a treat!
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Ned October 04, 2011 @ 4:18pm
You are a my second time life-savior.
Thanks a million Rick! You are a Star!!!
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by TarandeepKaur October 12, 2011 @ 11:51am
Excellent post. Thanks a lot!
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Fred James October 25, 2011 @ 6:09am
I had this issue after installing .NET 1.1 on my machine. After visiting several sites which made my situation worse, a quick system restore and your suggestions fixed everything. Thanks a lot really great post :)
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by bazzagan November 14, 2011 @ 12:20pm
Top man Rick, installed .net 1.1 and it screwed up all my sites. Your tip was a lifesaver as the aspnet_regiis.exe -r solved nothing!

Cheers mate
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Jaime Fuhr December 05, 2011 @ 5:28pm
Many thanks for this post. Like the last two comments, I installed 1.1 to test an older version of our product.

Glad I stumbled across this!
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Alex Weinle January 26, 2012 @ 3:20am
Really useful - seems a crying shame that this happens out of the box - great advice though as always. I completely removed the un-bited entry and it works like a charm. Cheers.
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Frank S. March 09, 2012 @ 7:27am
Rick Thanks worked like a charm. Frank S.
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Bill Loytty March 21, 2012 @ 3:05am
This really saved me this morning...thanks for the post.
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Franklin March 29, 2012 @ 12:29pm
You saved my day man! I tried the aspnet_regiis option. did not work. I thought i had to reinstall all the shit again. Thanks to you i can sleept his night, instead of work :-)
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Al April 05, 2012 @ 9:40am
Well written - Great article!!! Has anyone experienced the case where a web app (due to using 64 bit database drivers) requires that the app pool be set to 32 bit enabled=false but the web app would like to use a 32 bit ISAPI filter dll? Looks like IIS fails to load the 32 bit ISAPI dll in the 64 bit web app worker process...is there a config setting for this?
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Sudarsan May 14, 2012 @ 6:55am
It is a great article. Thank you very much for posting. It worked like a charm and saved my life..
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by leo_21 May 18, 2012 @ 2:52pm
I was loosing hope and thinking I'd had to reinstall IIS but thanks to you I've got it fixed so many thanks. In adition to your port the modiffication can be done not only over the website but over the whole server just choosing the server and then the Configuration Editor so if one adds new pages then, they won't get misconfigured cause the global config should be fine, many thanks for this post, as some said this post should be the first result google must show.
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Klaus Graefensteiner July 05, 2012 @ 5:13pm
I had the same issue. I followed your instructions and noticed that the isapi entry in question had an extra backslash in the path. I removed the extra backslash and the sites where coming up with the 64-bit app pool. I ended up not removing the entry. I also installed the .NET framework 1.1 and a lot of other stuff on a Windows 2008 R2 Server.
Thanks for this great article.
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Mahyar November 17, 2012 @ 11:22am
Thank you alot
that's weird, but this problem happened to me suddenly this morning while all things were allright 2 days ago. :-) funny
I also noticed that I have already removed that generic row for one of my 2008 servers with IIS7 sometime ago, but I don't know why I did that :-|

Anyway, thanks again
Your trouble-shootings and guides has always saved us
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Darin April 05, 2013 @ 7:35am
It's funny, I get this error almost every time I setup a new site on a couple of servers we have and I forget this every single time. AND I always seem to find my way to this post in my search. We love you, man.
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Joel April 29, 2013 @ 8:14am
"c:\windows\Microsoft.NET\Framework\v4.0.30319\\aspnet_filter.dll"

If you notice in your screenshot it has two slashes between v4.0.30319 and aspnet_filter.dll. After removing one of the slashes it was reported to me that the error no longer occurred.

Also, on your screenshot of the ISAPI Filter screen. You can just right click on the entry and say edit.
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Rodrigo February 13, 2014 @ 3:35pm
Dude you're my life-saver!
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Ing. Jorge Leal April 28, 2014 @ 4:26pm
Thank´s a lot,

has Solved my problem.

Best Regards
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Nnergy June 18, 2014 @ 9:12am
One word. Excellent!
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
by Vlad October 13, 2014 @ 6:21am
Thank you for posting this, helped me a lot. While searching for answers I saw that everyone else was happy with just enabling 32 bit apps on the application pool, you were among the few that were concerned about the root problem.

Cheers!
 


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