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
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:
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:
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:
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.
Other Posts you might also like
The Voices of Reason
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
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
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
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
Thanks a million Rick! You are a Star!!!
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
Cheers mate
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
Glad I stumbled across this!
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
Thanks for this great article.
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
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
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on 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
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
has Solved my problem.
Best Regards
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
Cheers!
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
Thank you so much. In my version, the bitness was set, but the "runtimeVersion4.0" was missing for the 32bit entry.
Thank you.
# re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll