Somewhere around October 2011 a bugfixed version 1.2.11 of log4net has been released. As log4net is around for years, I guess most people like myself did not update it on day zero.
Today I’ve decided to update one of our applications to use the newest version of log4net and immediately bumped into issues.
First, it seems that for some reason they have signed the newest version of log4net 1.2.11 with a different key. If your application uses any external component (a *.dll) relying on 1.2.10 (and I bet you have such components), the new key means that assembly rebinding will not be possible! In other words, the runtime will not be able to pretend that the new log4net 1.2.11 loaded with your module is the same log4net 1.2.10 which is required by one of your external components.
But hey, they have a workaround for this! It seems that they have two different releases. One is signed with the new key and the other with the old key.
Supposedly then, if you download the 1.2.11 signed with the old key and you rebind the 1.2.10 to 1.2.11 it should work.
So how do you rebind? There are two possible approaches.
A static rebind is just a matter of your configuration file.
A dynamic rebind is a matter of the AssemblyResolve event handler:
So now, no matter which approach you take, it should work. And guess what - unfortunately, it doesn’t.
The reason is really unfortunate. It seems that they have changed the signature of the XmlConfigurator.Configure() method between releases! To me it’s unacceptable, it’s against OOP to break backward compatibility at the object contract level between two minor releases.
In 1.2.10 the Configure method returns void.
In 1.2.11 the Configure method returns ICollection.
The exact problem of the rebinding is then
TypeInitializationException: Method not found: 'Void log4net.Config.XmlConfigurator.Configure()'.
and of course the method is not found as someone has decided to change its signature in 1.2.11! In other words then, the external component referencing 1.2.10 calls XmlConfigurator.Configure() and finds the method in 1.2.11 you provide. But since the method’s signature has changed, the type loader raises the exception and definitely should raise it as calling the method with wrong signature could blow up your runtime because of stack issues.
To me it’s a super fail from the log4net team. The release notes mentions this as one of "new features":
I guess my migration to 1.2.11 has ended prematurely.