Click here to Skip to main content
15,614,257 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am currently using log4net 1.2.10 for logging in my project. Now i need to refer to an assembly that uses log4net 1.2.13 internally for logging. Now this new assembly throws an exception ("Unable to load assembly 1.2.13";) while i run the project.

since there are numerous changes in the log4net 1.2.10 to 1.2.13, i just can not migrate my logging code to 1.2.13. Thus i need to have some solution where i could keep my logging code with 1.2.10 & can also use new assembly that uses log4net 1.2.13.

Any help would be appreciated.

This is what i have already tried.

a) used two folder to keep two different version & set the codebase against version in webconfig's runtime tag. But no luck.

What I have tried:

used two diffrent folders to keep two different versions of log4net & set the codebase against version in webconfig's runtime tag. But no luck.
Updated 21-Jul-16 22:51pm
Rob Philpott 22-Jul-16 3:36am    
I would think seriously about switching to the new version and updating your logging code. This would not normally be required as I'm sure they maintain backward compatibility for all the normal cases.

Side-by-side/assembly redirection is something to avoid unless absolutely necessary.

1 solution

You can change your code to use the latest version (surely that won't be hard? it's only logging). Or if the assemblies are compatible you can use assembly redirection to have your code load the 1.2.13 assembly even though it is referencing an older version

Redirecting Assembly Versions[^]

As I said though, that will only work if the assemblies are backward compatible.

The third option is to use both assemblies. This is possible, but awkward. You might need to google for more detailed info but if you look at the properties of the reference in VS you’ll see an "Aliases" field that will be "global". In your reference to the older version change that Aliases field to something like "oldlog4net". Now in your code anything that references "log4net.SomeClass" will use the later version, and you change your code to reference "oldlog4net::log4net.SomeClass" and that will use the assembly you referenced with the "oldlog4net" alias.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900