Referencing 2 different versions of log4net in the same solution
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Having two projects in one solution reference different versions of log4net is possible at development time, but what matters is the final runtime boundary. If those projects end up inside one executable or one hosting process, you usually want to converge on a single log4net version. Running two versions side by side in one application is not the normal or maintainable answer.
Solution-Level Versus Process-Level Reality
A Visual Studio solution can contain many projects, and each project can reference a different package version while you are coding. That alone is not the real problem.
The real question is this:
- do the projects build into separate applications or services
- or do they end up loaded into the same process
If they are separate executables, each app can usually carry its own dependency version independently.
If they land in one executable, web app, Windows service, or test host, dependency resolution becomes a runtime issue rather than just a project-file issue.
The Usual Best Answer: Unify the Version
For one final application, the cleanest path is usually to upgrade the projects to one log4net version and test that upgrade properly.
That gives you:
- one assembly version to deploy
- fewer binding problems
- simpler debugging
- fewer surprises from API differences
If the APIs you use are compatible, this is almost always preferable to trying to keep two versions alive.
What Binding Redirects Actually Do
In classic .NET Framework applications, binding redirects can map older version requests to one chosen version.
This does not mean you are truly using two versions. It means you are forcing the application to use one chosen version at runtime.
That is often exactly what you want.
When True Separation Is Required
If one component absolutely depends on a version that cannot be unified, the practical solutions are architectural isolation, not a clever package trick.
Typical isolation strategies are:
- separate process or service
- separate executable tools
- plugin or legacy boundary with a clearly isolated runtime
Trying to keep two incompatible versions of the same logging library in one normal application usually creates more complexity than it saves.
Wrapper Abstractions Help
If several projects use log4net directly, version upgrades become painful because the logging library leaks everywhere. A useful long-term fix is to hide the dependency behind your own small abstraction.
For example, instead of calling log4net directly in every project, expose an interface such as IAppLogger. Then only one integration layer depends on the concrete logging framework.
That will not magically solve the immediate version conflict, but it makes future upgrades much easier.
Common Pitfalls
The most common mistake is treating the solution file as the real deployment boundary. It is not. The runtime boundary is the process.
Another mistake is assuming binding redirects let you safely run two versions at once. They usually redirect everyone to one version.
A third pitfall is spending too much effort on assembly gymnastics when the better fix is to upgrade or isolate the older component.
Summary
- Different projects in one solution can reference different versions during development, but the final process boundary is what matters.
- If multiple projects end up in one application, the best answer is usually to unify on one
log4netversion. - Binding redirects in .NET Framework resolve to one chosen version rather than preserving two runtime versions.
- If true separation is required, isolate the components into separate processes or services.
- Wrapping the logging framework behind your own abstraction reduces future version pain.
Related reading
- Refresh DataGridView when updating data source
- Regarding usage of Task.Start , Task.Run and Task.Factory.StartNew
- Register for COM Interop vs Make assembly COM visible
- Reinforcement learning in C
- Refname 'master' is ambiguous
- rejected master - master non-fast-forward
- Release generating .pdb files, why?
- Reliably stop System.Threading.Timer?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.