You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by "Philip Lee (JIRA)" <ji...@apache.org> on 2013/11/11 16:34:17 UTC

[jira] [Commented] (LOG4NET-393) Using dynamic methods with log4net causes NullReferenceException in StackFrameItem

    [ https://issues.apache.org/jira/browse/LOG4NET-393?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13819029#comment-13819029 ] 

Philip Lee commented on LOG4NET-393:
------------------------------------

I've just hit the same issue.  It occurs in ASP.NET FormView when one of the attached methods is called, e.g. UpdateMethod="foo".
When will the fix be available on NuGet?

> Using dynamic methods with log4net causes NullReferenceException in StackFrameItem
> ----------------------------------------------------------------------------------
>
>                 Key: LOG4NET-393
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-393
>             Project: Log4net
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.2.12
>         Environment: VS2012, Windows 7
>            Reporter: W.R. Dittmer
>            Priority: Blocker
>             Fix For: 1.2.13
>
>         Attachments: Log4netLambaExpressionTest.zip
>
>
> 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: {System.Object lambda_method(System.Runtime.CompilerServices.Closure)}
> then one cannot access the DeclaringType. The code then tries to get the FullName of the null value which causes the exception.
> According to: http://msdn.microsoft.com/en-us/library/system.reflection.emit.dynamicmethod.declaringtype.aspx
> "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'.



--
This message was sent by Atlassian JIRA
(v6.1#6144)