Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4net dependency problem

I have an issue with log4net which has been bugging me for a while and I've resolved to sort it.

I have a class library which references log4net. If I reference this class library in another project I must then reference log4net in this project otherwise I get a build error

Unknown build error, 'Cannot resolve dependency to assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.' 

I'm aware that the error message is probably telling me the solution, unfortunately I don't speak gibberish...

Cheers guys

Alex..

like image 777
Fergal Moran Avatar asked Apr 13 '10 13:04

Fergal Moran


People also ask

Could not load file or assembly log4net or one of its dependencies?

Solution 1 Just remove it from the dll from your project and then try to build the project. Since you don't need that one. In case you want to include that dll, you should check that, the application pool you are using is compatible with the assembly.

What is log4net dll?

dll in Solution. Log4net is an open-source project based on the work of many authors. It allows the developer to control what log statements are output with arbitrary granularity. It is fully configurable at runtime using external configuration files.

Why use log4net?

log4net is a tool to help the programmer output log statements to a variety of output targets. In case of problems with an application, it is helpful to enable logging so that the problem can be located. With log4net it is possible to enable logging at runtime without modifying the application binary.


1 Answers

Here is the link which describes what is happening and how to fix it:

https://docs.microsoft.com/en-us/archive/blogs/jmstall/viewing-types-with-reflection-only

An excerpt from the above link:

So what happened was that it tried to get the System.Type for Bar, but to resolve the type it needs to load the base class, which is in another dll. Reflection-Only context doesn't do binding policy so it can't find that dll. The LoaderException hint says to use the ReflectionOnlyAssemblyResolve, which provides more information about this.

To use the reflection API, you have to resolve all the dependencies used.

like image 56
kemiller2002 Avatar answered Sep 21 '22 07:09

kemiller2002