The above scenario gave me the well-known could not load file or assembly error message. The assembly that couldn’t be found was ‘log4net, Version=188.8.131.52, Culture=neutral, PublicKeyToken=692fbea5521e1304’. Or one of its dependencies of course… The situation in which I was getting this error message:
- using the CrystalReportViewer in an ASP.NET application
- having the ASP.NET application hosted in IIS (the error did not occur on the ASP.NET Development Server)
- running on a 64 bit machine
Log4net was available in the GAC, with the exact version and PublicKeyToken stated in the error message. So that couldn’t be the problem. Or could it…? Having a second (and closer) look at the log4net assembly in the GAC one thing stood out.
The Processor Architecture for the log4net assembly is set to x86. That means it can’t be loaded by IIS, which is x64 on this machine. OK, so now we know what’s wrong. Next: how to solve this?
I tried several things to get my (x64) IIS, Crystal Reports and log4net to get to play together nicely. Things that did not help to get this problem fixed included removing log4net from the assemblies section of the web.config, kicking my machine around the office and trying to recompile log4net for the x64 architecture.
As far as I have been able to find out, these two steps will get it working:
- Enable 32 bit ASP.NET IIS integration
Open a command prompt, go to the non x64 framework folder of your choice (for instance C:WindowsMicrosoft.NETFrameworkv4.0.30319) and execute “aspnet_regiis –enable –i”
- Enable 32 bit apps for 64 bit IIS
Open a command prompt and execute “cscript.exe %SystemDrive%inetpubAdminScriptsadsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 true”
If you do not have the admin scripts installed, install the from the ‘Turn Windows features on or off’ option in your Control Panel. The scripts are located under Internet Information Services – Web Management Tools – IIS 6 Management Compatibility – IIS 6 Scripting Tools.
I’m not sure of any negative side-effects at this point. If I run into any in the future I’ll let you know. For now my application is working like a charm!
Hope this helps.