C# – Error with Log4Net : “Could not load file or assembly ‘log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies”

asp.netasp.net-mvcasp.net-mvc-4clog4net

When trying to run a MVC sample provided by a Vendor for trialling a API, I get the following error:

[StructureMapConfigurationException: StructureMap configuration
failures: Error: 170 Source: Registry:
StructureMap.Configuration.DSL.Registry, StructureMap,
Version=2.6.3.0, Culture=neutral, PublicKeyToken=e60ad81abae3c223
Unable to find the exported Type's in assembly
Groupdocs.Web.UI.Comparison, Version=2.0.5205.21794, Culture=neutral,
PublicKeyToken=c9073b8a6a9c78c8. One or more of the assembly's
dependencies may be missing.

Could not load file or assembly 'log4net, Version=1.2.10.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies. A
strongly-named assembly is required. (Exception from HRESULT:
0x80131044) System.IO.FileLoadException: Could not load file or
assembly 'log4net, Version=1.2.10.0, Culture=neutral,
PublicKeyToken=null' or one of its dependencies. A strongly-named
assembly is required. (Exception from HRESULT: 0x80131044) File name:
'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly
assembly, ObjectHandleOnStack retTypes) at
System.Reflection.RuntimeAssembly.GetExportedTypes() at
StructureMap.Graph.TypePool.<>c__DisplayClass2.<.ctor>b__0(Assembly
assembly)

Seems specifically to do with Log4net but I have got the correct reference for the project and version (1.2.10), interestingly when I try the same project from another machine it works so not sure what the actual issue is.
I have checked the GAC and there are no log4net references.

Best Answer

The error says: "A strongly-named assembly is required"

I think you should either add a strong named key to the log4net that you use, or remove a strong named key from your application.