log4net issue - deploying onto Azure Windows Server 2012 (IIS8)

Topics: Troubleshooting
Aug 9, 2013 at 8:50 PM
I keep getting this error:
Could not load file or assembly 'log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The system cannot find the file specified. 

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The system cannot find the file specified.
I built on VS and had it hosted on my local, no issues. I built precompiled, no issues. Now when I put it in a VM, it gets that. Any ideas guys? :(
Aug 9, 2013 at 9:39 PM
Please I really need your help guys. I need to get this out in an hour.
Aug 9, 2013 at 9:54 PM
Even a fresh copy of Orchard 1.7 is getting this issue :/
Aug 9, 2013 at 10:38 PM
When you say "VM," do you mean (a) an Azure IaaS virtual machine, (b) an Azure Cloud Service (Web role), or (c) an Azure Website?

If (b) or (c), try this:
  1. Expand the Web project's References
  2. Find the reference for log4net
  3. Right-click, choose Properties
  4. Ensure that "Copy Local" is True.
If (a), could you describe your deployment scenario in more detail?
Aug 9, 2013 at 10:56 PM
I think it would be A. I provisioned a Windows Server 2012 instance. Got in and enabled IIS.

Got my precompiled build of Orchard and set it up in IIS. I browse or go localhost and then I see the error. It's very frustrating. I downloaded a fresh copy of 1.7, built precompiled and uploaded and set it up. Same problem. :(

I tried Server 2008 R2 as well, even installed .NET 4.5 then got the same error.
Aug 9, 2013 at 11:10 PM
Couple of things:
  1. Verify that the correct log4net.dll is in the application's bin folder. If not, copy it in. Log4net is probably not installed on the VM, so it's probably not in the GAC.
  2. Turn on assembly binding logging: http://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net. You can read the fusion log with the fusion log viewer: http://msdn.microsoft.com/en-us/library/e74a18c4.aspx. That will tell you exactly what the CLR is doing to find the log4net.dll file.
Aug 9, 2013 at 11:20 PM
You are a life saver. I just needed no.1. THANK YOU VERY MUCH