Runtime error, "Could not load file or assembly 'log4net,"

Topics: General, Installing BugNET
Aug 9, 2012 at 12:31 AM

I had a .9xx version installed and I downloaded the source for 1.0 today.  It compiles without error, but when I run it I get the following:

Could not load file or assembly 'log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

The version in the project was 1.2.10.

I downloaded 1.2.11 and I tried to replace all references, but I still get this error.  I can only find 1.2.11 on my machine and it's not in the GAC.

Any ideas?

Aug 9, 2012 at 2:13 PM

The version in this release was rolled back to 1.2.10 due to issues in 1.12.11.  

Your web.config may be referencing the old version ?  See this post - http://bugnet.codeplex.com/discussions/390484

Aug 9, 2012 at 6:22 PM

I searched the entire solution for 1.2.11 and didn't find it.  It's definitely not in the web.config file, in fact there's no reference to log4net there.

I read the post you referenced and all of those changes are already in the web.config I just downloaded.

Aug 9, 2012 at 7:57 PM

Open all of the *.csproj files in Notepad and make sure that the log4net reference element is like so.

    <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\packages\log4net.1.2.10\lib\2.0\log4net.dll</HintPath>
    </Reference>

Aug 9, 2012 at 10:02 PM
Edited Aug 9, 2012 at 10:03 PM

Updated all of the .csproj files (only 7 of them were incorrect).  It's still giving the error, but it's changed slightly.

[FileLoadException: Could not load file or assembly 'log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   BugNET.Global..cctor() +0

[TypeInitializationException: The type initializer for 'BugNET.Global' threw an exception.]
   BugNET.Global..ctor() +0
   ASP.global_asax..ctor() +61

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1136
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +23
   System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +60
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +259
   System.Web.HttpApplicationFactory.FireApplicationOnStart(HttpContext context) +9196508
   System.Web.HttpApplicationFactory.EnsureAppStartCalled(HttpContext context) +187
   System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +92
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +327

I cleaned and rebuilt the solution several times.
Aug 9, 2012 at 10:15 PM

Are you trying to compile the source from the zip file or the codeplex repository?

Aug 9, 2012 at 10:40 PM

ZIP file

Aug 10, 2012 at 1:08 AM

Hmmm I just downloaded the zip file, built and deployed on my test environment and it all worked.

Can you go through all the steps you have done from compile to deploy?

Thanks

Aug 10, 2012 at 10:58 PM

I had an existing version both on me development machine and my server.

I extracted all of the files from the archive into the existing build directory.  Compiled it in VS, then published it to the server.

I had to edit the web.config to point to my SQL Server, but I made no other changes.

Aug 11, 2012 at 1:55 PM

What you might try is deleting the contents of the bin folder and copy the updated compiled dlls again.  If you are doing a "Release" build the dlls are actually compiled to the src\build\output folder so you will need to grab them from there rather than the web\bin folder

Aug 11, 2012 at 5:51 PM

I nuked the entire build directory and install directory on the server, extracted everything from the archive and built it.  It built and ran without errors on my dev machine.

Initially it tried to upgrade the DB, but had lots of failures because the user in the web config wasn't dbo for the BugNet schema.  However, even though it failed, it let me continue to the site.  This failed due to missing DB objects.  So I had to manually run the upgrade scripts to get the DB up to the latest rev.  After that I was able to bring up the site and login on my dev machine.

Oddly, when I published, not all of the dlls were copied to the server so I had to manually copy them.

Everything appears to be working now.

Thanks.

Aug 12, 2012 at 3:07 PM

Glad you were able to solve and fix your issues