In our production code we use dynamic methods e.g. when using the factory pattern. We upgraded from 1.2.10 to 1.2.12 and encountered the following exception:
log4net:ERROR An exception ocurred while retreiving stack frame information.
System.NullReferenceException: Object reference not set to an instance of an object.
at log4net.Core.StackFrameItem..ctor(StackFrame frame) in c:\Users\wilfred.dittmer\Documents\Visual Studio 2012\Projects\Log4netLambaExpressionTest\log4net-1.2.12-src\log4net-1.2.12\src\Core\StackFrameItem.cs:line 61
I created a test project (attached) which shows the exception occuring.
If the method is:
then one cannot access the DeclaringType. The code then tries to get the FullName of the null value which causes the exception.
"DynamicMethod.DeclaringType: Gets the type that declares the method, which is always null for dynamic methods."
So it seems best to check if DeclaringType is null and if so leave the m_className set to 'NA'.